PHP Class Knp\Bundle\MenuBundle\Templating\Helper\MenuHelper

Inheritance: extends Symfony\Component\Templating\Helper\Helper
Show file Open project: KnpLabs/KnpMenuBundle Class Usage Examples

Public Methods

Method Description
__construct ( Knp\Menu\Twig\Helper $helper, Knp\Menu\Matcher\MatcherInterface $matcher, Knp\Menu\Util\MenuManipulator $menuManipulator )
get ( Knp\Menu\ItemInterface | string $menu, array $path = [], array $options = [] ) : Knp\Menu\ItemInterface Retrieves an item following a path in the tree.
getBreadcrumbsArray ( Knp\Menu\ItemInterface | array | string $menu, string | array | null $subItem = null ) : array Returns an array ready to be used for breadcrumbs.
getCurrentItem ( Knp\Menu\ItemInterface | array | string $menu ) : Knp\Menu\ItemInterface | null Returns the current item of a menu.
getName ( ) : string
getPathAsString ( Knp\Menu\ItemInterface $menu, string $separator = ' > ' ) : string A string representation of this menu item
isAncestor ( Knp\Menu\ItemInterface $item, integer $depth = null ) : boolean Checks whether an item is the ancestor of a current item.
isCurrent ( Knp\Menu\ItemInterface $item ) : boolean Checks whether an item is current.
render ( Knp\Menu\ItemInterface | string | array $menu, array $options = [], string $renderer = null ) : string Renders a menu with the specified renderer.

Method Details

__construct() public method

public __construct ( Knp\Menu\Twig\Helper $helper, Knp\Menu\Matcher\MatcherInterface $matcher, Knp\Menu\Util\MenuManipulator $menuManipulator )
$helper Knp\Menu\Twig\Helper
$matcher Knp\Menu\Matcher\MatcherInterface
$menuManipulator Knp\Menu\Util\MenuManipulator

get() public method

Retrieves an item following a path in the tree.
public get ( Knp\Menu\ItemInterface | string $menu, array $path = [], array $options = [] ) : Knp\Menu\ItemInterface
$menu Knp\Menu\ItemInterface | string
$path array
$options array
return Knp\Menu\ItemInterface

getBreadcrumbsArray() public method

Returns an array ready to be used for breadcrumbs.
public getBreadcrumbsArray ( Knp\Menu\ItemInterface | array | string $menu, string | array | null $subItem = null ) : array
$menu Knp\Menu\ItemInterface | array | string
$subItem string | array | null
return array

getCurrentItem() public method

Returns the current item of a menu.
public getCurrentItem ( Knp\Menu\ItemInterface | array | string $menu ) : Knp\Menu\ItemInterface | null
$menu Knp\Menu\ItemInterface | array | string
return Knp\Menu\ItemInterface | null

getName() public method

public getName ( ) : string
return string

getPathAsString() public method

e.g. Top Level 1 > Second Level > This menu
public getPathAsString ( Knp\Menu\ItemInterface $menu, string $separator = ' > ' ) : string
$menu Knp\Menu\ItemInterface
$separator string
return string

isAncestor() public method

Checks whether an item is the ancestor of a current item.
public isAncestor ( Knp\Menu\ItemInterface $item, integer $depth = null ) : boolean
$item Knp\Menu\ItemInterface
$depth integer The max depth to look for the item
return boolean

isCurrent() public method

Checks whether an item is current.
public isCurrent ( Knp\Menu\ItemInterface $item ) : boolean
$item Knp\Menu\ItemInterface
return boolean

render() public method

Renders a menu with the specified renderer.
public render ( Knp\Menu\ItemInterface | string | array $menu, array $options = [], string $renderer = null ) : string
$menu Knp\Menu\ItemInterface | string | array
$options array
$renderer string
return string