Class Menu

Summary

Fully Qualified Name: Zend\View\Helper\Navigation\Menu
Extends: AbstractHelper

Description

Helper for rendering menus from navigation containers.

Methods

Name Description Defined By
__call() Magic overload: Proxy calls to the navigation container AbstractHelper
__invoke() View helper entry point. Menu
__toString() Magic overload: Proxy to {@link render()}. AbstractHelper
accept() Determines whether a page should be accepted when iterating AbstractHelper
escapeLabels() Sets a flag indicating whether labels should be escaped. Menu
findActive() Finds the deepest active page in the given container AbstractHelper
getAcl() Returns ACL or null if it isn't set using {@link setAcl()} or {@link setDefaultAcl()} AbstractHelper
getAddClassToListItem() Returns flag indicating whether page class should be applied to
  • element.
  • Menu
    getContainer() Returns the navigation container helper operates on by default AbstractHelper
    getEventManager() Get the event manager, if present. AbstractHelper
    getIndent() Returns indentation AbstractHelper
    getLiActiveClass() Returns CSS class to use for the active 'li' element when rendering. Menu
    getMaxDepth() Returns maximum depth a page can have to be included when rendering AbstractHelper
    getMinDepth() Returns minimum depth a page must have to be included when rendering AbstractHelper
    getOnlyActiveBranch() Returns a flag indicating whether only active branch should be rendered. Menu
    getPartial() Returns partial view script to use for rendering menu. Menu
    getRenderInvisible() Return renderInvisible flag AbstractHelper
    getRenderParents() Returns flag indicating whether parents should be rendered when rendering only the active branch. Menu
    getRole() Returns ACL role to use when iterating pages, or null if it isn't set using {@link setRole()} or {@link setDefaultRole()} AbstractHelper
    getServiceLocator() Get the service locator. AbstractHelper
    getUlClass() Returns CSS class to use for the first 'ul' element when rendering. Menu
    getUseAcl() Returns whether ACL should be used AbstractHelper
    hasAcl() Checks if the helper has an ACL instance AbstractHelper
    hasContainer() Checks if the helper has a container AbstractHelper
    hasRole() Checks if the helper has an ACL role AbstractHelper
    htmlify() Returns an HTML string containing an 'a' element for the given page if the page's href is not empty, and a 'span' element if it is empty. Menu
    render() Renders menu. Menu
    renderMenu() Renders helper. Menu
    renderPartial() Renders the given $container by invoking the partial view helper. Menu
    renderPartialWithParams() Renders the given $container by invoking the partial view helper with the given parameters as the model. Menu
    renderSubMenu() Renders the inner-most sub menu for the active page in the $container. Menu
    setAcl() Sets ACL to use when iterating pages AbstractHelper
    setAddClassToListItem() Enables/disables page class applied to
  • element.
  • Menu
    setContainer() Sets navigation container the helper operates on by default AbstractHelper
    setDefaultAcl() Sets default ACL to use if another ACL is not explicitly set AbstractHelper
    setDefaultRole() Sets default ACL role(s) to use when iterating pages if not explicitly set later with {@link setRole()} AbstractHelper
    setEventManager() Set the event manager. AbstractHelper
    setIndent() Set the indentation string for using in {@link render()}, optionally a number of spaces to indent with AbstractHelper
    setLiActiveClass() Sets CSS class to use for the active 'li' element when rendering. Menu
    setMaxDepth() Sets the maximum depth a page can have to be included when rendering AbstractHelper
    setMinDepth() Sets the minimum depth a page must have to be included when rendering AbstractHelper
    setOnlyActiveBranch() Sets a flag indicating whether only active branch should be rendered. Menu
    setPartial() Sets which partial view script to use for rendering menu. Menu
    setRenderInvisible() Render invisible items? AbstractHelper
    setRenderParents() Enables/disables rendering of parents when only rendering active branch. Menu
    setRole() Sets ACL role(s) to use when iterating pages AbstractHelper
    setServiceLocator() Set the service locator. AbstractHelper
    setUlClass() Sets CSS class to use for the first 'ul' element when rendering. Menu
    setUseAcl() Sets whether ACL should be used AbstractHelper

    Method Details

    __call()

    Magic overload: Proxy calls to the navigation container

    Parameter Name Type Description
    $method string method
    $arguments array rguments

    Returns: mixed

    __invoke()

    View helper entry point.

    Retrieves helper and optionally sets container to operate on.

    Parameter Name Type Description
    $container \AbstractContainer [optional]

    Returns: self

    __toString()

    Magic overload: Proxy to {@link render()}.

    This method will trigger an E_USER_ERROR if rendering the helper causes an exception to be thrown.

    Implements {@link HelperInterface::__toString()}.

    Returns: string

    accept()

    Determines whether a page should be accepted when iterating

    Default listener may be 'overridden' by attaching listener to 'isAllowed' method. Listener must be 'short circuited' if overriding default ACL listener.

    Rules:

    Parameter Name Type Description
    $page \AbstractPage page
    $recursive bool [optional]

    Returns: bool Whether page should be accepted

    escapeLabels()

    Sets a flag indicating whether labels should be escaped.

    Parameter Name Type Description
    $flag bool [optional]

    Returns: self

    findActive()

    Finds the deepest active page in the given container

    Parameter Name Type Description
    $container \Navigation\AbstractContainer container
    $minDepth int|null [optional]
    $maxDepth int|null [optional]

    Returns: array an associative array with the values 'depth' and 'page', or an empty array if not found

    getAcl()

    Returns ACL or null if it isn't set using {@link setAcl()} or {@link setDefaultAcl()}

    Implements {@link HelperInterface::getAcl()}.

    Returns: \Acl\AclInterface|null ACL object or null

    getAddClassToListItem()

    Returns flag indicating whether page class should be applied to

  • element.

    By default, this value is false.

    Returns: bool whether parents should be rendered

    getContainer()

    Returns the navigation container helper operates on by default

    Implements {@link HelperInterface::getContainer()}.

    If no container is set, a new container will be instantiated and stored in the helper.

    Returns: \Navigation\AbstractContainer navigation container

    getEventManager()

    Get the event manager, if present.

    Internally, the helper will lazy-load an EM instance the first time it requires one, but ideally it should be injected during instantiation.

    Returns: null|\EventManagerInterface

    getIndent()

    Returns indentation

    Returns: string

    getLiActiveClass()

    Returns CSS class to use for the active 'li' element when rendering.

    Returns: string

    getMaxDepth()

    Returns maximum depth a page can have to be included when rendering

    Returns: int|null

    getMinDepth()

    Returns minimum depth a page must have to be included when rendering

    Returns: int|null

    getOnlyActiveBranch()

    Returns a flag indicating whether only active branch should be rendered.

    By default, this value is false, meaning the entire menu will be be rendered.

    Returns: bool

    getPartial()

    Returns partial view script to use for rendering menu.

    Returns: string|array|null

    getRenderInvisible()

    Return renderInvisible flag

    Returns: bool

    getRenderParents()

    Returns flag indicating whether parents should be rendered when rendering only the active branch.

    By default, this value is true.

    Returns: bool

    getRole()

    Returns ACL role to use when iterating pages, or null if it isn't set using {@link setRole()} or {@link setDefaultRole()}

    Implements {@link HelperInterface::getRole()}.

    Returns: string|\Acl\Role\RoleInterface|null

    getServiceLocator()

    Get the service locator.

    Used internally to pull named navigation containers to render.

    Returns: \ContainerInterface

    getUlClass()

    Returns CSS class to use for the first 'ul' element when rendering.

    Returns: string

    getUseAcl()

    Returns whether ACL should be used

    Implements {@link HelperInterface::getUseAcl()}.

    Returns: bool

    hasAcl()

    Checks if the helper has an ACL instance

    Implements {@link HelperInterface::hasAcl()}.

    Returns: bool

    hasContainer()

    Checks if the helper has a container

    Implements {@link HelperInterface::hasContainer()}.

    Returns: bool

    hasRole()

    Checks if the helper has an ACL role

    Implements {@link HelperInterface::hasRole()}.

    Returns: bool

    htmlify()

    Returns an HTML string containing an 'a' element for the given page if the page's href is not empty, and a 'span' element if it is empty.

    Overrides {@link AbstractHelper::htmlify()}.

    Parameter Name Type Description
    $page \AbstractPage page
    $escapeLabel bool Whether
    $addClassToListItem bool Whether

    Returns: string

    render()

    Renders menu.

    Implements {@link HelperInterface::render()}.

    If a partial view is registered in the helper, the menu will be rendered using the given partial script. If no partial is registered, the menu will be rendered as an 'ul' element by the helper's internal method.

    Parameter Name Type Description
    $container \AbstractContainer [optional]

    Returns: string

    renderMenu()

    Renders helper.

    Renders a HTML 'ul' for the given $container. If $container is not given, the container registered in the helper will be used.

    Available $options:

    Parameter Name Type Description
    $container \AbstractContainer [optional]
    $options array [optional]

    Returns: string

    renderPartial()

    Renders the given $container by invoking the partial view helper.

    The container will simply be passed on as a model to the view script as-is, and will be available in the partial script as 'container', e.g. echo 'Number of pages: ', count($this->container);.

    Parameter Name Type Description
    $container null|\AbstractContainer [optional]
    $partial null|string|array [optional]

    Returns: string

    renderPartialWithParams()

    Renders the given $container by invoking the partial view helper with the given parameters as the model.

    The container will simply be passed on as a model to the view script as-is, and will be available in the partial script as 'container', e.g. echo 'Number of pages: ', count($this->container);.

    Any parameters provided will be passed to the partial via the view model.

    Parameter Name Type Description
    $container null|\AbstractContainer [optional]
    $partial null|string|array [optional]
    $params

    Returns: string

    renderSubMenu()

    Renders the inner-most sub menu for the active page in the $container.

    This is a convenience method which is equivalent to the following call: renderMenu($container, array(

    'indent'           => $indent,
    'ulClass'          => $ulClass,
    'minDepth'         => null,
    'maxDepth'         => null,
    'onlyActiveBranch' => true,
    'renderParents'    => false,
    'liActiveClass'    => $liActiveClass
    

    ));

    Parameter Name Type Description
    $container \AbstractContainer [optional]
    $ulClass string [optional]
    $indent string|int [optional]
    $liActiveClass string [optional]

    Returns: string

    setAcl()

    Sets ACL to use when iterating pages

    Implements {@link HelperInterface::setAcl()}.

    Parameter Name Type Description
    $acl \Acl\AclInterface ACL

    Returns: \AbstractHelper

    setAddClassToListItem()

    Enables/disables page class applied to

  • element.

    Parameter Name Type Description
    $flag bool [optional]

    Returns: self fluent interface, returns self

    setContainer()

    Sets navigation container the helper operates on by default

    Implements {@link HelperInterface::setContainer()}.

    Parameter Name Type Description
    $container string|\Navigation\AbstractContainer Default

    Returns: \AbstractHelper

    setDefaultAcl()

    Sets default ACL to use if another ACL is not explicitly set

    Parameter Name Type Description
    $acl \Acl\AclInterface [optional]

    Returns: void

    setDefaultRole()

    Sets default ACL role(s) to use when iterating pages if not explicitly set later with {@link setRole()}

    Parameter Name Type Description
    $role mixed [optional]

    Returns: void

    setEventManager()

    Set the event manager.

    Parameter Name Type Description
    $events \EventManagerInterface

    Returns: \AbstractHelper

    setIndent()

    Set the indentation string for using in {@link render()}, optionally a number of spaces to indent with

    Parameter Name Type Description
    $indent string|int

    Returns: \AbstractHelper

    setLiActiveClass()

    Sets CSS class to use for the active 'li' element when rendering.

    Parameter Name Type Description
    $liActiveClass string CSS

    Returns: self

    setMaxDepth()

    Sets the maximum depth a page can have to be included when rendering

    Parameter Name Type Description
    $maxDepth int Default

    Returns: \AbstractHelper

    setMinDepth()

    Sets the minimum depth a page must have to be included when rendering

    Parameter Name Type Description
    $minDepth int Default

    Returns: \AbstractHelper

    setOnlyActiveBranch()

    Sets a flag indicating whether only active branch should be rendered.

    Parameter Name Type Description
    $flag bool [optional]

    Returns: self

    setPartial()

    Sets which partial view script to use for rendering menu.

    Parameter Name Type Description
    $partial string|array partial

    Returns: self

    setRenderInvisible()

    Render invisible items?

    Parameter Name Type Description
    $renderInvisible bool

    Returns: \AbstractHelper

    setRenderParents()

    Enables/disables rendering of parents when only rendering active branch.

    See {@link setOnlyActiveBranch()} for more information.

    Parameter Name Type Description
    $flag bool [optional]

    Returns: self

    setRole()

    Sets ACL role(s) to use when iterating pages

    Implements {@link HelperInterface::setRole()}.

    Parameter Name Type Description
    $role mixed [optional]

    Returns: \AbstractHelper

    setServiceLocator()

    Set the service locator.

    Used internally to pull named navigation containers to render.

    Parameter Name Type Description
    $serviceLocator \ContainerInterface

    Returns: \AbstractHelper

    setUlClass()

    Sets CSS class to use for the first 'ul' element when rendering.

    Parameter Name Type Description
    $ulClass string CSS

    Returns: self

    setUseAcl()

    Sets whether ACL should be used

    Implements {@link HelperInterface::setUseAcl()}.

    Parameter Name Type Description
    $useAcl bool

    Returns: \AbstractHelper

  • Top