PHP Класс Menu\Items\ItemList

Наследование: extends Menu\Traits\MenuObject
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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 ) : ItemList Add an active pattern to the ItemList instance.
add ( string $url, string $value, ItemList $children = null, array $linkAttributes = [], array $itemAttributes = [], string $itemElement = null, string $beforeContent = null, string $afterContent = null ) : ItemList Add a link item to the ItemList instance.
addContent ( Content $content, ItemList $children = null, array $itemAttributes = [], string $itemElement = null, string $beforeContent = null, string $afterContent = null ) Add content to the ItemList
attach ( ItemList $itemList ) : ItemList 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 ) : ItemList Easily create items while looping over DB results that have a reference to the parent (usually via parentId)
map ( $callback )
name ( string $name ) : ItemList Set the name for this ItemList
onItem ( ) : Item Get the last Item
prefix ( string $prefix ) : ItemList Prefix this ItemList with a string
prefixMenuHandler ( boolean $prefixMenuHandler = true ) : ItemList Prefix this ItemList with the name of the ItemList at the very top of the tree
prefixParents ( boolean $prefixParents = true ) : ItemList Prefix this ItemList with the parent ItemList(s) name(s)
raw ( string $raw, ItemList $children = null, array $itemAttributes = [], string $itemElement = null, string $beforeContent = null, string $afterContent = null ) : ItemList 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

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

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

Create a new Item List instance
public __construct ( $items = [], string $name = null, array $attributes = [], string $element = null ) : void
$name string The ItemList's name
$attributes array Attributes for the ItemList's HMTL element
$element string The HTML element for the ItemList
Результат void

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

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 ) : ItemList
$pattern string
Результат ItemList

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

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, ItemList $children = null, array $linkAttributes = [], array $itemAttributes = [], string $itemElement = null, string $beforeContent = null, string $afterContent = null ) : ItemList
$url string Url of the link
$value string (H)T(ML) inside of the link
$children ItemList 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
Результат ItemList

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

Add content to the ItemList
public addContent ( Content $content, ItemList $children = null, array $itemAttributes = [], string $itemElement = null, string $beforeContent = null, string $afterContent = null )
$content Content Content object
$children ItemList 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() публичный Метод

Attach menu items to the default MenuHandler Menu::attach(Menu::items()->add('home', 'Homepage'));
public attach ( ItemList $itemList ) : ItemList
$itemList ItemList
Результат ItemList

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

public breadcrumbs ( )

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

alias for findItemListByName
public find ( $name ) : Vespakoen\Menu\Items\ItemLists | false
Результат Vespakoen\Menu\Items\ItemLists | false

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

public findActiveItem ( )

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

alias for findItemListByName
public findByName ( $name ) : Vespakoen\Menu\Items\ItemLists | false
Результат Vespakoen\Menu\Items\ItemLists | false

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

Find an item by an attribute
public findItemByAttribute ( $key, $value ) : Vespakoen\Menu\Items\Item | false
Результат Vespakoen\Menu\Items\Item | false

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

Find an item by it's link's URL
public findItemByUrl ( $url ) : Vespakoen\Menu\Items\Item | false
Результат Vespakoen\Menu\Items\Item | false

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

Find an itemlist by it's name
public findItemListByName ( $name ) : Vespakoen\Menu\Items\ItemLists | false
Результат Vespakoen\Menu\Items\ItemLists | false

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

Get all itemlists
public getAllItemLists ( ) : Vespakoen\Menu\MenuHandler
Результат Vespakoen\Menu\MenuHandler

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

Get all itemslists including this one
public getAllItemListsIncludingThisOne ( ) : Vespakoen\Menu\MenuHandler
Результат Vespakoen\Menu\MenuHandler

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

Get all items
public getAllItems ( ) : Vespakoen\Menu\MenuHandler
Результат Vespakoen\Menu\MenuHandler

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

Get the Item's element
public getElement ( ) : string
Результат string

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

Get itemlists at a certain depth
public getItemListsAtDepth ( $depth ) : Vespakoen\Menu\MenuHandler
Результат Vespakoen\Menu\MenuHandler

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

Get itemlists in a range of depths
public getItemListsAtDepthRange ( $from, $to ) : Vespakoen\Menu\MenuHandler
Результат Vespakoen\Menu\MenuHandler

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

Get all itemlists for an itemlsit recursively for a specific depth
protected getItemListsRecursivelyWithDepth ( $itemList, $depth ) : array
Результат array

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

Get all itemlists with the depth as key
public getItemListsWithDepth ( ) : array
Результат array

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

Get all items at a certain depth
public getItemsAtDepth ( $depth ) : Vespakoen\Menu\MenuHandler
Результат Vespakoen\Menu\MenuHandler

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

Get items in a range of depths
public getItemsAtDepthRange ( $from, $to ) : Vespakoen\Menu\MenuHandler
Результат Vespakoen\Menu\MenuHandler

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

Get items by their content type
public getItemsByContentType ( string $contentType ) : VEspakoen\Menu\MenuHandler
$contentType string The full object name
Результат VEspakoen\Menu\MenuHandler

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

Get all items for an array of items recursively for a specific depth
protected getItemsRecursivelyWithDepth ( $items, $depth ) : array
Результат array

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

Get all items with the depth as key
public getItemsWithDepth ( ) : array
Результат array

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

Get the name of the ItemList
public getName ( ) : string
Результат string Name of the ItemList

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

public getSubmenu ( )

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

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 ) : ItemList
$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
Результат ItemList the

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

public map ( $callback )

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

Set the name for this ItemList
public name ( string $name ) : ItemList
$name string
Результат ItemList

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

Get the last Item
public onItem ( ) : Item
Результат Item

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

Prefix this ItemList with a string
public prefix ( string $prefix ) : ItemList
$prefix string
Результат ItemList

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

Prefix this ItemList with the name of the ItemList at the very top of the tree
public prefixMenuHandler ( boolean $prefixMenuHandler = true ) : ItemList
$prefixMenuHandler boolean
Результат ItemList

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

Prefix this ItemList with the parent ItemList(s) name(s)
public prefixParents ( boolean $prefixParents = true ) : ItemList
$prefixParents boolean
Результат ItemList

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

Add a raw item to the default main menu Menu::raw('');
public raw ( string $raw, ItemList $children = null, array $itemAttributes = [], string $itemElement = null, string $beforeContent = null, string $afterContent = null ) : ItemList
$raw string The raw content
$children ItemList 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
Результат ItemList

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

Get the evaluated string content of the ItemList.
public render ( integer $depth ) : string
$depth integer The depth at which the ItemList should be rendered
Результат string

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

public reverse ( )

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

Set the Item's element
public setElement ( string $element = null )
$element string

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

Set a particular option in the array
public setOption ( string $option, mixed $value ) : Menu\Traits\MenuObject
$option string The option
$value mixed Its new value
Результат Menu\Traits\MenuObject

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

$name публичное свойство

The name of this ItemList
public string $name
Результат string