PHP Class Networking\InitCmsBundle\Menu\MenuBuilder

Author: Yorkie Chadwick ([email protected])
Show file Open project: networking/init-cms-bundle

Protected Properties

Property Type Description
$authorizationChecker Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
$currentPath string
$currentUri string
$factory Knp\Menu\FactoryInterface
$isLoggedIn boolean
$matcher Knp\Menu\Matcher\Matcher
$menuIterators array
$menuManager Networking\InitCmsBundle\Model\MenuItemManagerInterface
$request Symfony\Component\HttpFoundation\Request
$router Symfony\Component\Routing\RouterInterface
$tokenStorage Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
$translator Symfony\Component\Translation\TranslatorInterface
$viewStatus string

Public Methods

Method Description
__construct ( Knp\Menu\FactoryInterface $factory, Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokenStorage, Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $authorizationChecker, Symfony\Component\HttpFoundation\RequestStack $requestStack, Symfony\Component\Routing\RouterInterface $router, Networking\InitCmsBundle\Model\MenuItemManagerInterface $menuManager, Symfony\Component\Translation\TranslatorInterface $translator, Knp\Menu\Matcher\Matcher $matcher ) MenuBuilder constructor.
addMenuIterator ( $menuName, $iterator )
addNodeToMenu ( Knp\Menu\MenuItem $menu, Networking\InitCmsBundle\Entity\MenuItem $node, $startDepth ) : boolean | Knp\Menu\ItemInterface Add a menu item node at the correct place in the menu
addVoter ( $path )
createFromMenuItem ( Networking\InitCmsBundle\Entity\MenuItem $menuItem ) : Knp\Menu\ItemInterface Create an new node using the ContentRoute object to generate the uri
createLoginMenu ( string $classes = 'nav pull-right' ) : Knp\Menu\ItemInterface Creates the login and change language navigation for the right side of the top frontend navigation
createMenu ( Knp\Menu\MenuItem $menu, array $menuIterator, integer $startDepth ) : Knp\Menu\MenuItem Creates a full menu based on the starting point given
getFullMenu ( string $menuName ) : array | boolean Retrieve the full menu tree
getMenuIterators ( ) : array
getParentMenu ( Knp\Menu\MenuItem $menu, Networking\InitCmsBundle\Entity\MenuItem $childNode ) : mixed Recursively get parents
getSubMenu ( string $menuName, integer $level = 1 ) : array | boolean Retrieves the sub menu array based on the current url
setCurrentPath ( )
setCurrentUri ( )
setLoggedIn ( )
setRecursiveAttribute ( Knp\Menu\ItemInterface $menu, array $attr ) Recursively set attributes on an item and its' children
setRecursiveChildrenAttribute ( Knp\Menu\ItemInterface $menu, array $attr ) Recursively set attributes on all children of a given menu
setViewStatus ( )
showOnlyCurrentChildren ( Knp\Menu\ItemInterface $menu ) Set the children menu item nodes to be shown only if the node is current or the parent is a current ancestor

Method Details

__construct() public method

MenuBuilder constructor.
public __construct ( Knp\Menu\FactoryInterface $factory, Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokenStorage, Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $authorizationChecker, Symfony\Component\HttpFoundation\RequestStack $requestStack, Symfony\Component\Routing\RouterInterface $router, Networking\InitCmsBundle\Model\MenuItemManagerInterface $menuManager, Symfony\Component\Translation\TranslatorInterface $translator, Knp\Menu\Matcher\Matcher $matcher )
$factory Knp\Menu\FactoryInterface
$tokenStorage Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
$authorizationChecker Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
$requestStack Symfony\Component\HttpFoundation\RequestStack
$router Symfony\Component\Routing\RouterInterface
$menuManager Networking\InitCmsBundle\Model\MenuItemManagerInterface
$translator Symfony\Component\Translation\TranslatorInterface
$matcher Knp\Menu\Matcher\Matcher

addMenuIterator() public method

public addMenuIterator ( $menuName, $iterator )
$menuName
$iterator

addNodeToMenu() public method

Add a menu item node at the correct place in the menu
public addNodeToMenu ( Knp\Menu\MenuItem $menu, Networking\InitCmsBundle\Entity\MenuItem $node, $startDepth ) : boolean | Knp\Menu\ItemInterface
$menu Knp\Menu\MenuItem
$node Networking\InitCmsBundle\Entity\MenuItem
$startDepth
return boolean | Knp\Menu\ItemInterface

addVoter() public method

public addVoter ( $path )
$path string

createFromMenuItem() public method

Create an new node using the ContentRoute object to generate the uri
public createFromMenuItem ( Networking\InitCmsBundle\Entity\MenuItem $menuItem ) : Knp\Menu\ItemInterface
$menuItem Networking\InitCmsBundle\Entity\MenuItem
return Knp\Menu\ItemInterface

createLoginMenu() public method

Creates the login and change language navigation for the right side of the top frontend navigation
public createLoginMenu ( string $classes = 'nav pull-right' ) : Knp\Menu\ItemInterface
$classes string
return Knp\Menu\ItemInterface

createMenu() public method

Creates a full menu based on the starting point given
public createMenu ( Knp\Menu\MenuItem $menu, array $menuIterator, integer $startDepth ) : Knp\Menu\MenuItem
$menu Knp\Menu\MenuItem
$menuIterator array
$startDepth integer
return Knp\Menu\MenuItem

getFullMenu() public method

Retrieve the full menu tree
public getFullMenu ( string $menuName ) : array | boolean
$menuName string
return array | boolean

getMenuIterators() public method

public getMenuIterators ( ) : array
return array

getParentMenu() public method

Recursively get parents
public getParentMenu ( Knp\Menu\MenuItem $menu, Networking\InitCmsBundle\Entity\MenuItem $childNode ) : mixed
$menu Knp\Menu\MenuItem - menu to look for the parent in
$childNode Networking\InitCmsBundle\Entity\MenuItem - menu node whose parent we are looking for
return mixed

getSubMenu() public method

Retrieves the sub menu array based on the current url
public getSubMenu ( string $menuName, integer $level = 1 ) : array | boolean
$menuName string
$level integer
return array | boolean

setCurrentPath() public method

public setCurrentPath ( )

setCurrentUri() public method

public setCurrentUri ( )

setLoggedIn() public method

public setLoggedIn ( )

setRecursiveAttribute() public method

Recursively set attributes on an item and its' children
public setRecursiveAttribute ( Knp\Menu\ItemInterface $menu, array $attr )
$menu Knp\Menu\ItemInterface
$attr array

setRecursiveChildrenAttribute() public method

Recursively set attributes on all children of a given menu
Deprecation: please use setRecursiveAttribute
public setRecursiveChildrenAttribute ( Knp\Menu\ItemInterface $menu, array $attr )
$menu Knp\Menu\ItemInterface
$attr array

setViewStatus() public method

public setViewStatus ( )

showOnlyCurrentChildren() public method

Set the children menu item nodes to be shown only if the node is current or the parent is a current ancestor
public showOnlyCurrentChildren ( Knp\Menu\ItemInterface $menu )
$menu Knp\Menu\ItemInterface

Property Details

$authorizationChecker protected property

protected AuthorizationCheckerInterface,Symfony\Component\Security\Core\Authorization $authorizationChecker
return Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface

$currentPath protected property

protected string $currentPath
return string

$currentUri protected property

protected string $currentUri
return string

$factory protected property

protected FactoryInterface,Knp\Menu $factory
return Knp\Menu\FactoryInterface

$isLoggedIn protected property

protected bool $isLoggedIn
return boolean

$matcher protected property

protected Matcher,Knp\Menu\Matcher $matcher
return Knp\Menu\Matcher\Matcher

$menuIterators protected property

protected array $menuIterators
return array

$menuManager protected property

protected MenuItemManagerInterface,Networking\InitCmsBundle\Model $menuManager
return Networking\InitCmsBundle\Model\MenuItemManagerInterface

$request protected property

protected Request,Symfony\Component\HttpFoundation $request
return Symfony\Component\HttpFoundation\Request

$router protected property

protected RouterInterface,Symfony\Component\Routing $router
return Symfony\Component\Routing\RouterInterface

$tokenStorage protected property

protected TokenStorageInterface,Symfony\Component\Security\Core\Authentication\Token\Storage $tokenStorage
return Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface

$translator protected property

protected TranslatorInterface,Symfony\Component\Translation $translator
return Symfony\Component\Translation\TranslatorInterface

$viewStatus protected property

protected string $viewStatus
return string