Zend\Navigation\Container

AbstractContainer class for Zend\Navigation\Page classes.

package Default

 Methods

Magic overload: Proxy calls to finder methods

__call(string $method, array $arguments) 

Examples of finder calls: // METHOD // SAME AS $nav->findByLabel('foo'); // $nav->findOneBy('label', 'foo'); $nav->findOneByLabel('foo'); // $nav->findOneBy('label', 'foo'); $nav->findAllByClass('foo'); // $nav->findAllBy('class', 'foo');

Parameters

$method

string

method name

$arguments

array

method arguments

Exceptions

\Zend\Navigation\Exception\BadMethodCallException if method does not exist

Adds a page to the container

addPage(\Zend\Navigation\Page\AbstractPage|array|\Traversable $page) : \Zend\Navigation\AbstractContainer

This method will inject the container as the given page's parent by calling \Page\AbstractPage::setParent().

fluent This method is part of a fluent interface and will return the same instance

Parameters

$page

\Zend\Navigation\Page\AbstractPagearray\Traversable

page to add

Exceptions

\Zend\Navigation\Exception\InvalidArgumentException if page is invalid

Returns

\Zend\Navigation\AbstractContainerfluent interface, returns self

Adds several pages at once

addPages(array|\Traversable|\Zend\Navigation\AbstractContainer $pages) : \Zend\Navigation\AbstractContainer
fluent This method is part of a fluent interface and will return the same instance

Parameters

$pages

array\Traversable\Zend\Navigation\AbstractContainer

pages to add

Exceptions

\Zend\Navigation\Exception\InvalidArgumentException if $pages is not array, Traversable or AbstractContainer

Returns

\Zend\Navigation\AbstractContainerfluent interface, returns self

Returns number of pages in container

count() : integer

Implements Countable interface.

Returns

integernumber of pages in the container

Returns current page

current() : \Zend\Navigation\Page\AbstractPage

Implements RecursiveIterator interface.

Exceptions

\Zend\Navigation\Exception\OutOfBoundsException if the index is invalid

Returns

\Zend\Navigation\Page\AbstractPagecurrent page or null

Returns all child pages matching $property == $value, or an empty array if no pages are found

findAllBy(string $property, mixed $value) : array

Parameters

$property

string

name of property to match against

$value

mixed

value to match property against

Returns

arrayarray containing only Page\AbstractPage instances

Returns page(s) matching $property == $value

findBy(string $property, mixed $value, boolean $all = false) : \Zend\Navigation\Page\AbstractPage | null

Parameters

$property

string

name of property to match against

$value

mixed

value to match property against

$all

boolean

[optional] whether an array of all matching pages should be returned, or only the first. If true, an array will be returned, even if not matching pages are found. If false, null will be returned if no matching page is found. Default is false.

Returns

\Zend\Navigation\Page\AbstractPagenullmatching page or null

Returns a child page matching $property == $value, or null if not found

findOneBy(string $property, mixed $value) : \Zend\Navigation\Page\AbstractPage | null

Parameters

$property

string

name of property to match against

$value

mixed

value to match property against

Returns

\Zend\Navigation\Page\AbstractPagenullmatching page or null

Returns the child container.

getChildren() : \Zend\Navigation\Page\AbstractPage | null

Implements RecursiveIterator interface.

Returns

\Zend\Navigation\Page\AbstractPagenull

Returns pages in the container

getPages() : array

Returns

arrayarray of Page\AbstractPage instances

Proxy to hasPages()

hasChildren() : boolean

Implements RecursiveIterator interface.

Returns

booleanwhether container has any pages

Checks if the container has the given page

hasPage(\Zend\Navigation\Page\AbstractPage $page, boolean $recursive = false) : boolean

Parameters

$page

\Zend\Navigation\Page\AbstractPage

page to look for

$recursive

boolean

[optional] whether to search recursively. Default is false.

Returns

booleanwhether page is in container

Returns true if container contains any pages

hasPages(boolean $onlyVisible = false) : boolean

Parameters

$onlyVisible

boolean

whether to check only visible pages

Returns

booleanwhether container has any pages

Returns hash code of current page

key() : string

Implements RecursiveIterator interface.

Returns

stringhash code of current page

Moves index pointer to next page in the container

next() : void

Implements RecursiveIterator interface.

Notifies container that the order of pages are updated

notifyOrderUpdated() : void

Removes the given page from the container

removePage(\Zend\Navigation\Page\AbstractPage|integer $page, boolean $recursive = false) : boolean

Parameters

$page

\Zend\Navigation\Page\AbstractPageinteger

page to remove, either a page instance or a specific page order

$recursive

boolean

[optional] whether to remove recursively

Returns

booleanwhether the removal was successful

Removes all pages in container

removePages() : \Zend\Navigation\AbstractContainer
fluent This method is part of a fluent interface and will return the same instance

Returns

\Zend\Navigation\AbstractContainerfluent interface, returns self

Sets index pointer to first page in the container

rewind() : void

Implements RecursiveIterator interface.

Sets pages this container should have, removing existing pages

setPages(array $pages) : \Zend\Navigation\AbstractContainer
fluent This method is part of a fluent interface and will return the same instance

Parameters

$pages

array

pages to set

Returns

\Zend\Navigation\AbstractContainerfluent interface, returns self

Returns an array representation of all pages in container

toArray() : array

Returns

array

Checks if container index is valid

valid() : boolean

Implements RecursiveIterator interface.

Returns

boolean

Sorts the page index according to page order

sort() : void

 Properties

 

Whether index is dirty and needs to be re-arranged

$dirtyIndex : boolean

Default

false
 

An index that contains the order in which to iterate pages

$index : array

Default

array()
 

Contains sub pages

$pages : array

Default

array()