Свойство | Тип | Описание | |
---|---|---|---|
$name | string | The name of this ItemList |
Метод | Описание | |
---|---|---|
__construct ( $items = [], string $name = null, array $attributes = [], string $element = null ) : void | Create a new Item List instance | |
activePattern ( string $pattern ) : |
Add an active pattern to the ItemList instance. | |
add ( string $url, string $value, |
Add a link item to the ItemList instance. | |
addContent ( Content $content, |
Add content to the ItemList | |
attach ( |
Add menu items to another ItemList. | |
breadcrumbs ( ) | ||
find ( $name ) : Vespakoen\Menu\Items\ItemLists | false | Find an itemlist by it's name | |
findActiveItem ( ) | ||
findByName ( $name ) : Vespakoen\Menu\Items\ItemLists | false | Find an itemlist by it's name | |
findItemByAttribute ( $key, $value ) : Vespakoen\Menu\Items\Item | false | Find an item by an attribute | |
findItemByUrl ( $url ) : Vespakoen\Menu\Items\Item | false | Find an item by it's link's URL | |
findItemListByName ( $name ) : Vespakoen\Menu\Items\ItemLists | false | Find an itemlist by it's name | |
getAllItemLists ( ) : Vespakoen\Menu\MenuHandler | Get all itemlists | |
getAllItemListsIncludingThisOne ( ) : Vespakoen\Menu\MenuHandler | Get all itemslists including this one | |
getAllItems ( ) : Vespakoen\Menu\MenuHandler | Get all items | |
getElement ( ) : string | Get the Item's element | |
getItemListsAtDepth ( $depth ) : Vespakoen\Menu\MenuHandler | Get itemlists at a certain depth | |
getItemListsAtDepthRange ( $from, $to ) : Vespakoen\Menu\MenuHandler | Get itemlists in a range of depths | |
getItemListsWithDepth ( ) : array | Get all itemlists with the depth as key | |
getItemsAtDepth ( $depth ) : Vespakoen\Menu\MenuHandler | Get all items at a certain depth | |
getItemsAtDepthRange ( $from, $to ) : Vespakoen\Menu\MenuHandler | Get items in a range of depths | |
getItemsByContentType ( string $contentType ) : VEspakoen\Menu\MenuHandler | Get items by their content type | |
getItemsWithDepth ( ) : array | Get all items with the depth as key | |
getName ( ) : string | Get the name of the ItemList | |
getSubmenu ( ) | ||
hydrate ( Closure $resolver, Closure $decorator, integer $idField = 'id', $parentIdField = 'parent_id', integer $parentId ) : |
Easily create items while looping over DB results that have a reference to the parent (usually via parentId) | |
map ( $callback ) | ||
name ( string $name ) : |
Set the name for this ItemList | |
onItem ( ) : |
Get the last Item | |
prefix ( string $prefix ) : |
Prefix this ItemList with a string | |
prefixMenuHandler ( boolean $prefixMenuHandler = true ) : |
Prefix this ItemList with the name of the ItemList at the very top of the tree | |
prefixParents ( boolean $prefixParents = true ) : |
Prefix this ItemList with the parent ItemList(s) name(s) | |
raw ( string $raw, |
Add a raw html item to the ItemList instance. | |
render ( integer $depth ) : string | Get the evaluated string content of the ItemList. | |
reverse ( ) | ||
setElement ( string $element = null ) | Set the Item's element | |
setOption ( string $option, mixed $value ) : Menu\Traits\MenuObject | Set a particular option in the array |
Метод | Описание | |
---|---|---|
getItemListsRecursivelyWithDepth ( $itemList, $depth ) : array | Get all itemlists for an itemlsit recursively for a specific depth | |
getItemsRecursivelyWithDepth ( $items, $depth ) : array | Get all items for an array of items recursively for a specific depth |
Add a item to the default menu and set an active class for /user/5/edit
Menu::add('user', 'Users')->activePattern('\/user\/\d\/edit');
public activePattern ( string $pattern ) : |
||
$pattern | string | |
Результат |
Add a item to the default menu
Menu::add('home', 'Homepage');
Add a item with a subitem to the default menu
Menu::add('home', 'Homepage', Menu::items()->add('home/sub', 'Subitem'));
Add a item with attributes for the item's HTML element
Menu::add('home', 'Homepage', null, array('class' => 'fancy'));
public add ( string $url, string $value, |
||
$url | string | Url of the link |
$value | string | (H)T(ML) inside of the link |
$children | Children | |
$linkAttributes | array | Attributes for the link |
$itemAttributes | array | Attributes for the item |
$itemElement | string | The element for the item |
$beforeContent | string | String to add before the link |
$afterContent | string | String to add after the link |
Результат |
public addContent ( Content $content, |
||
$content | Content | Content object |
$children | Children | |
$itemAttributes | array | Attributes for the item (li) |
$itemElement | string | Element for the item (li is default) |
$beforeContent | string | String to add before the content |
$afterContent | string | String to add after the content |
Attach menu items to the default MenuHandler
Menu::attach(Menu::items()->add('home', 'Homepage'));
public attach ( |
||
$itemList | ||
Результат |
public find ( $name ) : Vespakoen\Menu\Items\ItemLists | false | ||
Результат | Vespakoen\Menu\Items\ItemLists | false |
public findByName ( $name ) : Vespakoen\Menu\Items\ItemLists | false | ||
Результат | Vespakoen\Menu\Items\ItemLists | false |
public findItemByAttribute ( $key, $value ) : Vespakoen\Menu\Items\Item | false | ||
Результат | Vespakoen\Menu\Items\Item | false |
public findItemByUrl ( $url ) : Vespakoen\Menu\Items\Item | false | ||
Результат | Vespakoen\Menu\Items\Item | false |
public findItemListByName ( $name ) : Vespakoen\Menu\Items\ItemLists | false | ||
Результат | Vespakoen\Menu\Items\ItemLists | false |
public getAllItemLists ( ) : Vespakoen\Menu\MenuHandler | ||
Результат | Vespakoen\Menu\MenuHandler |
public getAllItemListsIncludingThisOne ( ) : Vespakoen\Menu\MenuHandler | ||
Результат | Vespakoen\Menu\MenuHandler |
public getAllItems ( ) : Vespakoen\Menu\MenuHandler | ||
Результат | Vespakoen\Menu\MenuHandler |
public getItemListsAtDepth ( $depth ) : Vespakoen\Menu\MenuHandler | ||
Результат | Vespakoen\Menu\MenuHandler |
public getItemListsAtDepthRange ( $from, $to ) : Vespakoen\Menu\MenuHandler | ||
Результат | Vespakoen\Menu\MenuHandler |
protected getItemListsRecursivelyWithDepth ( $itemList, $depth ) : array | ||
Результат | array |
public getItemListsWithDepth ( ) : array | ||
Результат | array |
public getItemsAtDepth ( $depth ) : Vespakoen\Menu\MenuHandler | ||
Результат | Vespakoen\Menu\MenuHandler |
public getItemsAtDepthRange ( $from, $to ) : Vespakoen\Menu\MenuHandler | ||
Результат | Vespakoen\Menu\MenuHandler |
public getItemsByContentType ( string $contentType ) : VEspakoen\Menu\MenuHandler | ||
$contentType | string | The full object name |
Результат | VEspakoen\Menu\MenuHandler |
protected getItemsRecursivelyWithDepth ( $items, $depth ) : array | ||
Результат | array |
public getItemsWithDepth ( ) : array | ||
Результат | array |
Menu::hydrate(function($parentId)
{
return Page::where('parent_id', $parentId)
->get();
},
function($children, $page)
{
$children->add($page->slug, $page->name);
});
public hydrate ( Closure $resolver, Closure $decorator, integer $idField = 'id', $parentIdField = 'parent_id', integer $parentId ) : |
||
$resolver | Closure | the callback to resolve results for a given parentId |
$decorator | Closure | the callback that modifies the ItemList for the given node |
$idField | integer | the id column that matches with the parentId |
$parentId | integer | the parentId to start hydrating from |
Результат | the |
public prefixMenuHandler ( boolean $prefixMenuHandler = true ) : |
||
$prefixMenuHandler | boolean | |
Результат |
public prefixParents ( boolean $prefixParents = true ) : |
||
$prefixParents | boolean | |
Результат |
Add a raw item to the default main menu
Menu::raw('');
public raw ( string $raw, |
||
$raw | string | The raw content |
$children | Children | |
$itemAttributes | array | The item attributes |
$itemElement | string | The item element |
$beforeContent | string | String to add before the raw content |
$afterContent | string | String to add after the raw content |
Результат |
public setElement ( string $element = null ) | ||
$element | string |