PHP Класс Lavary\Menu\Builder

This provides the basic functionality to add, update and fetch menu items attached to a menu. Most of the functionality of this class is invoked using the menu facade.
См. также: Facade
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$conf array The Menu configuration data
$groupStack array The route group attribute stack.
$items array The items container
$name string The Menu name
$reserved array The reserved attributes.

Открытые методы

Метод Описание
__call ( string $method, array $args ) : Lavary\Menu\Item Search the menu based on an attribute
__construct ( $name, $conf ) : void Initializing the menu manager
__get ( $prop ) : Lavary\Menu\Item Returns menu item by name
add ( string $title, $options = '' ) : Lavary\Menu\Item Adds an item to the menu
all ( ) : array Return all items in the collection
asDiv ( $attributes = [], $childrenAttributes = [] ) : string Returns the menu as div containers
asOl ( $attributes = [], $childrenAttributes = [] ) : string Returns the menu as an ordered list.
asUl ( $attributes = [], $childrenAttributes = [] ) : string Returns the menu as an unordered list.
attributes ( array $attributes ) : string Build an HTML attribute string from an array.
conf ( string $key ) : string Return configuration value by key
dispatch ( $options ) : string Get the form action from the options.
divide ( array $attributes = [] ) : void Insert a separator after the item
extractAttributes ( array $options = [] ) : array Get the valid attributes from the options.
filter ( callable $callback ) : Lavary\Menu\Builder Filter menu items by user callbacks
filterRecursive ( string $attribute, mixed $value ) : Lavary\Menu\Collection Filter items recursively
find ( $id ) : Lavary\Menu\Item Returns menu item by Id
first ( ) : Lavary\Menu\Item Return the first item in the collection
formatGroupClass ( $new, $old ) : string Get the valid attributes from the options.
formatGroupPrefix ( array $new, array $old ) : string Format the prefix for the new group attributes.
get ( $title ) : Lavary\Menu\Item Returns menu item by name
getLastGroupPrefix ( ) : string Get the prefix from the last group on the stack.
group ( array $attributes, callable $closure ) : void Create a menu group with shared attributes.
isAbs ( string $url ) : boolean Check if the given url is an absolute url.
item ( $title ) : Lavary\Menu\Item Returns menu item by name
last ( ) : Lavary\Menu\Item Return the last item in the collection
mergeStatic ( $new = null, array $old = [] ) : string Merge item's attributes with a static string of attributes
raw ( $title, array $options = [] ) : Lavary\Menu\Item Add raw content
render ( string $type = 'ul', integer $parent = null, $childrenAttributes = [] ) : string Generate the menu items as list items using a recursive function
roots ( ) : Collection Returns items with no parent
sortBy ( $sort_by, string | callable $sort_type = 'asc' ) : Lavary\Menu\Builder Sorts the menu based on user's callable

Защищенные методы

Метод Описание
attributeElement ( string $key, string $value ) : string Build a single attribute element.
getControllerAction ( array | string $options ) : string Get the action for an "action" option.
getRoute ( array | string $options ) : string Get the action for a "route" option.
getUrl ( array | string $options ) : string Get the action for a "url" option.
id ( ) : integer Generate an integer identifier for each new item
mergeGroup ( array $new, array $old ) : array Merge the given group attributes.
mergeWithLastGroup ( array $new ) : array Merge the given array with the last group stack.
prefix ( string $uri ) : string Prefix the given URI with the last prefix.
updateGroupStack ( array $attributes = [] ) : void Update the group stack with the given attributes.

Описание методов

__call() публичный Метод

Search the menu based on an attribute
public __call ( string $method, array $args ) : Lavary\Menu\Item
$method string
$args array
Результат Lavary\Menu\Item

__construct() публичный Метод

Initializing the menu manager
public __construct ( $name, $conf ) : void
Результат void

__get() публичный Метод

Returns menu item by name
public __get ( $prop ) : Lavary\Menu\Item
Результат Lavary\Menu\Item

add() публичный Метод

Adds an item to the menu
public add ( string $title, $options = '' ) : Lavary\Menu\Item
$title string
Результат Lavary\Menu\Item $item

all() публичный Метод

Return all items in the collection
public all ( ) : array
Результат array

asDiv() публичный Метод

Returns the menu as div containers
public asDiv ( $attributes = [], $childrenAttributes = [] ) : string
Результат string

asOl() публичный Метод

Returns the menu as an ordered list.
public asOl ( $attributes = [], $childrenAttributes = [] ) : string
Результат string

asUl() публичный Метод

Returns the menu as an unordered list.
public asUl ( $attributes = [], $childrenAttributes = [] ) : string
Результат string

attributeElement() защищенный статический Метод

Build a single attribute element.
protected static attributeElement ( string $key, string $value ) : string
$key string
$value string
Результат string

attributes() публичный статический Метод

Build an HTML attribute string from an array.
public static attributes ( array $attributes ) : string
$attributes array
Результат string

conf() публичный Метод

Return configuration value by key
public conf ( string $key ) : string
$key string
Результат string

dispatch() публичный Метод

Get the form action from the options.
public dispatch ( $options ) : string
Результат string

divide() публичный Метод

Insert a separator after the item
public divide ( array $attributes = [] ) : void
$attributes array
Результат void

extractAttributes() публичный Метод

Get the valid attributes from the options.
public extractAttributes ( array $options = [] ) : array
$options array
Результат array

filter() публичный Метод

Filter menu items by user callbacks
public filter ( callable $callback ) : Lavary\Menu\Builder
$callback callable
Результат Lavary\Menu\Builder

filterRecursive() публичный Метод

Filter items recursively
public filterRecursive ( string $attribute, mixed $value ) : Lavary\Menu\Collection
$attribute string
$value mixed
Результат Lavary\Menu\Collection

find() публичный Метод

Returns menu item by Id
public find ( $id ) : Lavary\Menu\Item
Результат Lavary\Menu\Item

first() публичный Метод

Return the first item in the collection
public first ( ) : Lavary\Menu\Item
Результат Lavary\Menu\Item

formatGroupClass() публичный статический Метод

Get the valid attributes from the options.
public static formatGroupClass ( $new, $old ) : string
Результат string

formatGroupPrefix() публичный статический Метод

Format the prefix for the new group attributes.
public static formatGroupPrefix ( array $new, array $old ) : string
$new array
$old array
Результат string

get() публичный Метод

Returns menu item by name
public get ( $title ) : Lavary\Menu\Item
Результат Lavary\Menu\Item

getControllerAction() защищенный Метод

Get the action for an "action" option.
protected getControllerAction ( array | string $options ) : string
$options array | string
Результат string

getLastGroupPrefix() публичный Метод

Get the prefix from the last group on the stack.
public getLastGroupPrefix ( ) : string
Результат string

getRoute() защищенный Метод

Get the action for a "route" option.
protected getRoute ( array | string $options ) : string
$options array | string
Результат string

getUrl() защищенный Метод

Get the action for a "url" option.
protected getUrl ( array | string $options ) : string
$options array | string
Результат string

group() публичный Метод

Create a menu group with shared attributes.
public group ( array $attributes, callable $closure ) : void
$attributes array
$closure callable
Результат void

id() защищенный Метод

Generate an integer identifier for each new item
protected id ( ) : integer
Результат integer

isAbs() публичный статический Метод

Check if the given url is an absolute url.
public static isAbs ( string $url ) : boolean
$url string
Результат boolean

item() публичный Метод

Returns menu item by name
public item ( $title ) : Lavary\Menu\Item
Результат Lavary\Menu\Item

last() публичный Метод

Return the last item in the collection
public last ( ) : Lavary\Menu\Item
Результат Lavary\Menu\Item

mergeGroup() защищенный статический Метод

Merge the given group attributes.
protected static mergeGroup ( array $new, array $old ) : array
$new array
$old array
Результат array

mergeStatic() публичный статический Метод

Merge item's attributes with a static string of attributes
public static mergeStatic ( $new = null, array $old = [] ) : string
$old array
Результат string

mergeWithLastGroup() защищенный Метод

Merge the given array with the last group stack.
protected mergeWithLastGroup ( array $new ) : array
$new array
Результат array

prefix() защищенный Метод

Prefix the given URI with the last prefix.
protected prefix ( string $uri ) : string
$uri string
Результат string

raw() публичный Метод

Add raw content
public raw ( $title, array $options = [] ) : Lavary\Menu\Item
$options array
Результат Lavary\Menu\Item

render() публичный Метод

Generate the menu items as list items using a recursive function
public render ( string $type = 'ul', integer $parent = null, $childrenAttributes = [] ) : string
$type string
$parent integer
Результат string

roots() публичный Метод

Returns items with no parent
public roots ( ) : Collection
Результат Illuminate\Support\Collection

sortBy() публичный Метод

Sorts the menu based on user's callable
public sortBy ( $sort_by, string | callable $sort_type = 'asc' ) : Lavary\Menu\Builder
$sort_type string | callable
Результат Lavary\Menu\Builder

updateGroupStack() защищенный Метод

Update the group stack with the given attributes.
protected updateGroupStack ( array $attributes = [] ) : void
$attributes array
Результат void

Описание свойств

$conf защищенное свойство

The Menu configuration data
protected array $conf
Результат array

$groupStack защищенное свойство

The route group attribute stack.
protected array $groupStack
Результат array

$items защищенное свойство

The items container
protected array $items
Результат array

$name защищенное свойство

The Menu name
protected string $name
Результат string

$reserved защищенное свойство

The reserved attributes.
protected array $reserved
Результат array