PHP Class Menu\Items\Item

Inheritance: extends Menu\Traits\MenuObject
Show file Open project: vespakoen/menu Class Usage Examples

Protected Properties

Property Type Description
$patterns array Array of patterns to match the active state

Public Methods

Method Description
__construct ( ItemList $parent, Tag $value, array $children = null, array $element = null, string $beforeContent = null, string $afterContent = null ) Create a new item instance
getContent ( ) : Menu\Traits\Content Get the Item's content
getElement ( ) : string Get the Item's element
getRequest ( ) : Request Get the Request instance
hasActiveChild ( ) : boolean Check if this item has an active child
hasChildren ( )
isActive ( ) : boolean Check if this item is active
render ( $depth ) : string Render the item
setActivePatterns ( string | array $pattern, string $name = null ) Add an pattern to $patterns array
setAfterContent ( string $value ) Set the value to be inserted after the item's content
setBeforeContent ( string $value ) Set the value to be inserted before the item's content
setElement ( string $element = null ) Set the Item's element
stop ( ) : ItemList Break off a chain

Protected Methods

Method Description
getUrl ( ) : string Get the url of the Item's content
hasActivePatterns ( ) : boolean Check if this item has an active pattern

Private Methods

Method Description
addActiveClasses ( ) Add the various active classes to an array of attributes

Method Details

__construct() public method

Create a new item instance
public __construct ( ItemList $parent, Tag $value, array $children = null, array $element = null, string $beforeContent = null, string $afterContent = null )
$parent ItemList The parent
$value HtmlObject\Traits\Tag The content
$children array Facultative children ItemLists
$element array The Item element
$beforeContent string String to add before the content
$afterContent string String to add after the content

getContent() public method

Get the Item's content
public getContent ( ) : Menu\Traits\Content
return Menu\Traits\Content

getElement() public method

Get the Item's element
public getElement ( ) : string
return string

getRequest() public method

Get the Request instance
public getRequest ( ) : Request
return Request

getUrl() protected method

Get the url of the Item's content
protected getUrl ( ) : string
return string

hasActiveChild() public method

Check if this item has an active child
public hasActiveChild ( ) : boolean
return boolean

hasActivePatterns() protected method

Check if this item has an active pattern
protected hasActivePatterns ( ) : boolean
return boolean

hasChildren() public method

public hasChildren ( )

isActive() public method

Check if this item is active
public isActive ( ) : boolean
return boolean

render() public method

Render the item
public render ( $depth ) : string
return string

setActivePatterns() public method

Add an pattern to $patterns array
public setActivePatterns ( string | array $pattern, string $name = null )
$pattern string | array The pattern
$name string Its name

setAfterContent() public method

Set the value to be inserted after the item's content
public setAfterContent ( string $value )
$value string The value to insert

setBeforeContent() public method

Set the value to be inserted before the item's content
public setBeforeContent ( string $value )
$value string The value to insert

setElement() public method

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

stop() public method

Break off a chain
public stop ( ) : ItemList
return ItemList

Property Details

$patterns protected property

Array of patterns to match the active state
protected array $patterns
return array