PHP Class Menu\Items\ItemList

Inheritance: extends Menu\Traits\MenuObject
Afficher le fichier Open project: vespakoen/menu Class Usage Examples

Méthodes publiques

Свойство Type Description
$name string The name of this ItemList

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
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

Method Details

__construct() public méthode

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
Résultat void

activePattern() public méthode

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
Résultat ItemList

add() public méthode

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
Résultat ItemList

addContent() public méthode

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() public méthode

Attach menu items to the default MenuHandler Menu::attach(Menu::items()->add('home', 'Homepage'));
public attach ( ItemList $itemList ) : ItemList
$itemList ItemList
Résultat ItemList

breadcrumbs() public méthode

public breadcrumbs ( )

find() public méthode

alias for findItemListByName
public find ( $name ) : Vespakoen\Menu\Items\ItemLists | false
Résultat Vespakoen\Menu\Items\ItemLists | false

findActiveItem() public méthode

public findActiveItem ( )

findByName() public méthode

alias for findItemListByName
public findByName ( $name ) : Vespakoen\Menu\Items\ItemLists | false
Résultat Vespakoen\Menu\Items\ItemLists | false

findItemByAttribute() public méthode

Find an item by an attribute
public findItemByAttribute ( $key, $value ) : Vespakoen\Menu\Items\Item | false
Résultat Vespakoen\Menu\Items\Item | false

findItemByUrl() public méthode

Find an item by it's link's URL
public findItemByUrl ( $url ) : Vespakoen\Menu\Items\Item | false
Résultat Vespakoen\Menu\Items\Item | false

findItemListByName() public méthode

Find an itemlist by it's name
public findItemListByName ( $name ) : Vespakoen\Menu\Items\ItemLists | false
Résultat Vespakoen\Menu\Items\ItemLists | false

getAllItemLists() public méthode

Get all itemlists
public getAllItemLists ( ) : Vespakoen\Menu\MenuHandler
Résultat Vespakoen\Menu\MenuHandler

getAllItemListsIncludingThisOne() public méthode

Get all itemslists including this one
public getAllItemListsIncludingThisOne ( ) : Vespakoen\Menu\MenuHandler
Résultat Vespakoen\Menu\MenuHandler

getAllItems() public méthode

Get all items
public getAllItems ( ) : Vespakoen\Menu\MenuHandler
Résultat Vespakoen\Menu\MenuHandler

getElement() public méthode

Get the Item's element
public getElement ( ) : string
Résultat string

getItemListsAtDepth() public méthode

Get itemlists at a certain depth
public getItemListsAtDepth ( $depth ) : Vespakoen\Menu\MenuHandler
Résultat Vespakoen\Menu\MenuHandler

getItemListsAtDepthRange() public méthode

Get itemlists in a range of depths
public getItemListsAtDepthRange ( $from, $to ) : Vespakoen\Menu\MenuHandler
Résultat Vespakoen\Menu\MenuHandler

getItemListsRecursivelyWithDepth() protected méthode

Get all itemlists for an itemlsit recursively for a specific depth
protected getItemListsRecursivelyWithDepth ( $itemList, $depth ) : array
Résultat array

getItemListsWithDepth() public méthode

Get all itemlists with the depth as key
public getItemListsWithDepth ( ) : array
Résultat array

getItemsAtDepth() public méthode

Get all items at a certain depth
public getItemsAtDepth ( $depth ) : Vespakoen\Menu\MenuHandler
Résultat Vespakoen\Menu\MenuHandler

getItemsAtDepthRange() public méthode

Get items in a range of depths
public getItemsAtDepthRange ( $from, $to ) : Vespakoen\Menu\MenuHandler
Résultat Vespakoen\Menu\MenuHandler

getItemsByContentType() public méthode

Get items by their content type
public getItemsByContentType ( string $contentType ) : VEspakoen\Menu\MenuHandler
$contentType string The full object name
Résultat VEspakoen\Menu\MenuHandler

getItemsRecursivelyWithDepth() protected méthode

Get all items for an array of items recursively for a specific depth
protected getItemsRecursivelyWithDepth ( $items, $depth ) : array
Résultat array

getItemsWithDepth() public méthode

Get all items with the depth as key
public getItemsWithDepth ( ) : array
Résultat array

getName() public méthode

Get the name of the ItemList
public getName ( ) : string
Résultat string Name of the ItemList

getSubmenu() public méthode

public getSubmenu ( )

hydrate() public méthode

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
Résultat ItemList the

map() public méthode

public map ( $callback )

name() public méthode

Set the name for this ItemList
public name ( string $name ) : ItemList
$name string
Résultat ItemList

onItem() public méthode

Get the last Item
public onItem ( ) : Item
Résultat Item

prefix() public méthode

Prefix this ItemList with a string
public prefix ( string $prefix ) : ItemList
$prefix string
Résultat ItemList

prefixMenuHandler() public méthode

Prefix this ItemList with the name of the ItemList at the very top of the tree
public prefixMenuHandler ( boolean $prefixMenuHandler = true ) : ItemList
$prefixMenuHandler boolean
Résultat ItemList

prefixParents() public méthode

Prefix this ItemList with the parent ItemList(s) name(s)
public prefixParents ( boolean $prefixParents = true ) : ItemList
$prefixParents boolean
Résultat ItemList

raw() public méthode

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
Résultat ItemList

render() public méthode

Get the evaluated string content of the ItemList.
public render ( integer $depth ) : string
$depth integer The depth at which the ItemList should be rendered
Résultat string

reverse() public méthode

public reverse ( )

setElement() public méthode

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

setOption() public méthode

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
Résultat Menu\Traits\MenuObject

Property Details

$name public_oe property

The name of this ItemList
public string $name
Résultat string