Overview

Namespaces

  • Menu
    • Items
      • Contents
    • Traits

Classes

  • Item
  • ItemList
  • Overview
  • Namespace
  • Class

Class ItemList

A container for Items

HtmlObject\Traits\Tag
Extended by Menu\Traits\MenuObject
Extended by Menu\Items\ItemList
Namespace: Menu\Items
Located at Menu/Items/ItemList.php
Methods summary
public
# __construct( string $items = array(), array $name = null, string $attributes = array(), $element = null )

Create a new Item List instance

Create a new Item List instance

Parameters

$items
$name The ItemList's name
$name
$attributes Attributes for the ItemList's HMTL element
$attributes
$element The HTML element for the ItemList
$element
public Menu\Items\Item
# onItem( )

Get the last Item

Get the last Item

Returns

Menu\Items\Item
public Menu\Traits\MenuObject
# setOption( string $option, mixed $value )

Set a particular option in the array

Set a particular option in the array

Parameters

$option
The option
$value
Its new value

Returns

Menu\Traits\MenuObject

Overrides

Menu\Traits\MenuObject::setOption()
public Menu\Items\ItemList
# add( string $url, string $value, Menu\Items\ItemList $children = null, array $linkAttributes = array(), array $itemAttributes = array(), string $itemElement = null, string $beforeContent = null, string $afterContent = null )

Add a link item to the ItemList instance.

Add a link item to the ItemList instance.

// 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'));

Parameters

$url
Url of the link
$value
(H)T(ML) inside of the link
$children
Children
$linkAttributes
Attributes for the link
$itemAttributes
Attributes for the item
$itemElement
The element for the item
$beforeContent
String to add before the link
$afterContent
String to add after the link

Returns

Menu\Items\ItemList
public Menu\Items\ItemList
# raw( string $raw, Menu\Items\ItemList $children = null, array $itemAttributes = array(), string $itemElement = null, string $beforeContent = null, string $afterContent = null )

Add a raw html item to the ItemList instance.

Add a raw html item to the ItemList instance.

// Add a raw item to the default main menu
   Menu::raw('<img src="img/seperator.gif">');

Parameters

$raw
The raw content
$children
Children
$itemAttributes
The item attributes
$itemElement
The item element
$beforeContent
String to add before the raw content
$afterContent
String to add after the raw content

Returns

Menu\Items\ItemList
public
# addContent( Content $content, Menu\Items\ItemList $children = null, array $itemAttributes = array(), string $itemElement = null, string $beforeContent = null, string $afterContent = null )

Add content to the ItemList

Add content to the ItemList

Parameters

$content
Content object
$children
Children
$itemAttributes
Attributes for the item (li)
$itemElement
Element for the item (li is default)
$beforeContent
String to add before the content
$afterContent
String to add after the content
public Menu\Items\ItemList
# activePattern( string $pattern )

Add an active pattern to the ItemList instance.

Add an active pattern to the ItemList instance.

// Add a item to the default menu and set an active class for /user/5/edit
   Menu::add('user', 'Users')->activePattern('\/user\/\d\/edit');

Parameters

$pattern

Returns

Menu\Items\ItemList
public Menu\Items\ItemList
# attach( Menu\Items\ItemList $itemList )

Add menu items to another ItemList.

Add menu items to another ItemList.

// Attach menu items to the default MenuHandler
   Menu::attach(Menu::items()->add('home', 'Homepage'));

Parameters

$itemList

Returns

Menu\Items\ItemList
public Menu\Items\ItemList
# name( string $name )

Set the name for this ItemList

Set the name for this ItemList

Parameters

$name

Returns

Menu\Items\ItemList
public string
# getName( )

Get the name of the ItemList

Get the name of the ItemList

Returns

string
Name of the ItemList
public Menu\Items\ItemList
# prefix( string $prefix )

Prefix this ItemList with a string

Prefix this ItemList with a string

Parameters

$prefix

Returns

Menu\Items\ItemList
public Menu\Items\ItemList
# prefixParents( boolean $prefixParents = true )

Prefix this ItemList with the parent ItemList(s) name(s)

Prefix this ItemList with the parent ItemList(s) name(s)

Parameters

$prefixParents

Returns

Menu\Items\ItemList
public Menu\Items\ItemList
# prefixMenuHandler( boolean $prefixMenuHandler = true )

Prefix this ItemList with the name of the ItemList at the very top of the tree

Prefix this ItemList with the name of the ItemList at the very top of the tree

Parameters

$prefixMenuHandler

Returns

Menu\Items\ItemList
public
# setElement( string $element = null )

Set the Item's element

Set the Item's element

Parameters

$element
public string
# getElement( )

Get the Item's element

Get the Item's element

Returns

string
public array
# getItemsWithDepth( )

Get all items with the depth as key

Get all items with the depth as key

Returns

array
protected array
# getItemsRecursivelyWithDepth( $items, $depth = 0 )

Get all items for an array of items recursively for a specific depth

Get all items for an array of items recursively for a specific depth

Returns

array
public array
# getItemListsWithDepth( )

Get all itemlists with the depth as key

Get all itemlists with the depth as key

Returns

array
protected array
# getItemListsRecursivelyWithDepth( $itemList, $depth = 0 )

Get all itemlists for an itemlsit recursively for a specific depth

Get all itemlists for an itemlsit recursively for a specific depth

Returns

array
public Vespakoen\Menu\MenuHandler
# getAllItems( )

Get all items

Get all items

Returns

Vespakoen\Menu\MenuHandler
public VEspakoen\Menu\MenuHandler
# getItemsByContentType( string $contentType )

Get items by their content type

Get items by their content type

Parameters

$contentType
The full object name

Returns

VEspakoen\Menu\MenuHandler
public Vespakoen\Menu\MenuHandler
# getAllItemLists( )

Get all itemlists

Get all itemlists

Returns

Vespakoen\Menu\MenuHandler
public Vespakoen\Menu\MenuHandler
# getAllItemListsIncludingThisOne( )

Get all itemslists including this one

Get all itemslists including this one

Returns

Vespakoen\Menu\MenuHandler
public Vespakoen\Menu\MenuHandler
# getItemListsAtDepth( $depth )

Get itemlists at a certain depth

Get itemlists at a certain depth

Returns

Vespakoen\Menu\MenuHandler
public Vespakoen\Menu\MenuHandler
# getItemListsAtDepthRange( $from, $to )

Get itemlists in a range of depths

Get itemlists in a range of depths

Returns

Vespakoen\Menu\MenuHandler
public Vespakoen\Menu\MenuHandler
# getItemsAtDepth( $depth )

Get all items at a certain depth

Get all items at a certain depth

Returns

Vespakoen\Menu\MenuHandler
public Vespakoen\Menu\MenuHandler
# getItemsAtDepthRange( $from, $to )

Get items in a range of depths

Get items in a range of depths

Returns

Vespakoen\Menu\MenuHandler
public
# reverse( )
public
# findActiveItem( )
public
# getSubmenu( )
public
# breadcrumbs( )
public
# map( $callback )
public Vespakoen\Menu\Items\ItemLists|false
# findItemListByName( $name )

Find an itemlist by it's name

Find an itemlist by it's name

Returns

Vespakoen\Menu\Items\ItemLists|false
public Vespakoen\Menu\Items\ItemLists|false
# findByName( $name )

Find an itemlist by it's name

Find an itemlist by it's name

alias for findItemListByName

Returns

Vespakoen\Menu\Items\ItemLists|false
public Vespakoen\Menu\Items\ItemLists|false
# find( $name )

Find an itemlist by it's name

Find an itemlist by it's name

alias for findItemListByName

Returns

Vespakoen\Menu\Items\ItemLists|false
public Vespakoen\Menu\Items\Item|false
# findItemByAttribute( $key, $value )

Find an item by an attribute

Find an item by an attribute

Returns

Vespakoen\Menu\Items\Item|false
public Vespakoen\Menu\Items\Item|false
# findItemByUrl( $url )

Find an item by it's link's URL

Find an item by it's link's URL

Returns

Vespakoen\Menu\Items\Item|false
public Menu\Items\ItemList
# hydrate( Closure $resolver, Closure $decorator, integer $idField = 'id', integer $parentIdField = 'parent_id', $parentId = 0 )

Easily create items while looping over DB results that have a reference to the parent (usually via parentId)

Easily create items while looping over DB results that have a reference to the parent (usually via parentId)

Menu::hydrate(function($parentId)
      {
        return Page::where('parent_id', $parentId)
          ->get();
      },
      function($children, $page)
      {
        $children->add($page->slug, $page->name);
      });

Parameters

$resolver
the callback to resolve results for a given parentId
$decorator
the callback that modifies the ItemList for the given node
$idField
the id column that matches with the parentId
$parentIdField
$parentId the parentId to start hydrating from
$parentId

Returns

Menu\Items\ItemList
the
public string
# render( integer $depth = 0 )

Get the evaluated string content of the ItemList.

Get the evaluated string content of the ItemList.

Parameters

$depth
The depth at which the ItemList should be rendered

Returns

string
Methods inherited from Menu\Traits\MenuObject
getOption(), replaceOptions()
Properties summary
public string $name

The name of this ItemList

The name of this ItemList

#
Properties inherited from Menu\Traits\MenuObject
$options
API documentation generated by ApiGen