PHP 클래스 Menu\Items\ItemList

상속: extends Menu\Traits\MenuObject
파일 보기 프로젝트 열기: vespakoen/menu 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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