承接 dluwang/navigator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dluwang/navigator

Composer 安装命令:

composer require dluwang/navigator

包简介

Navigator manager service

README 文档

README

Build Status Latest Stable Version License

This is a package that provide service to manage navigations

Note

Laravel Version Package Version
5.5 1.0.*
5.6 1.1.*
5.7 1.2.*
5.8 1.3.*

Installation

composer require dluwang/navigation

Usage

Define Navigation

Dluwang/Navigator/Navigation is a class to define your navigation. The __construct method has two mandatory arguments and four optional arguments

public function __construct($id, $url, $order = 1, $parent = null, array $attributes = [], array $childs = [])
  1. $id is the id of the navigation

  2. $url is the url of the navigation

  3. $order is number for sorting the navigation

  4. $parent is the parent of the navigation

  5. $attributes is the additional attributes of navigation

  6. $childs is the childs of navigation

All of the properties above can be accessed via the object instance.

Registering child

There are two ways to register navigation's child.

  • Eager child registration
$navigation->registerChild($childNavigation) // single child registration`

$navigation->registerChild([$childNavigation2, $childNavigation2]) // multiple childs registration
  • Deferred child registration

Sometimes you want to hook navigation and register the child somewhere in your app. You just need to specify the parent argument with the navigation-id you want to hook.

$navigation = new Navigation('navigation-id', 'the-url', 'the-order', 'the-parent-navigation-id');

Retrieveing all childs

$navigation->childs()

Retrievent child by id

$navigation->child('navigation-id-wanted')

Define Navigator

Dluwang/Navigator/BaseNavigator is a class that act as the repository of Navigations. All Navigator implementation should implements Dluwang/Navigator/Navigator interface.

$navigator = new BaseNavigator()

Constructor has one optional argument which is the navigations you want to register.

Registering navigations

$navigator->register($navigation) // single navigation registration
$navigator->register([$navigation1, $navigation2]) // mutiple navigations

As mentioned above, the deferred child can be registered casually to navigator.

Retrieve raw registered navigations

This package under the hood do some data preparation such as sorting and collect deferred childs. To get raw data you can use.

$navigator->raw();

To specify parent, use:

$navigator->raw('parent-id');

To get prepared data you can use the methods below.

Retrieve all navigations

$navigator->navigations()

You can specify the navigations loaded by their parent.

$navigator->navigations('parent-id');

Retrieve navigation by id

$navigator->navigation('navigation-id')

Integration

Currently, this package only integrated with laravel framework. You can register your defined navigation in you app service provider at the boot method. This integration add a caching mechanism when building navigation

public function boot() {

	// define navigation
	$navigation = ...

	$this->app->navigator->register($navigation);

}

Tests

To run test, run this following command

vendor/bin/phpunit

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固