Zend\Navigation\Container

AbstractContainer class for Zend\Navigation\Page classes.

 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\self

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

Parameters

$page

\Zend\Navigation\Page\AbstractPagearray\Traversable

page to add

Exceptions

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

Returns

\Zend\Navigation\selffluent interface, returns self

Adds several pages at once

addPages(array | \Traversable | \Zend\Navigation\AbstractContainer $pages) : \Zend\Navigation\self

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\selffluent interface, returns self

Returns number of pages in container

count() : int

Implements Countable interface.

Returns

intnumber 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

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, bool $all) : \Zend\Navigation\Page\AbstractPage | null

Parameters

$property

string

name of property to match against

$value

mixed

value to match property against

$all

bool

[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

Returns pages in the container

getPages() : array

Returns

arrayarray of Page\AbstractPage instances

Proxy to hasPages()

hasChildren() : bool

Implements RecursiveIterator interface.

Returns

boolwhether container has any pages

Checks if the container has the given page

hasPage(\Zend\Navigation\Page\AbstractPage $page, bool $recursive) : bool

Parameters

$page

\Zend\Navigation\Page\AbstractPage

page to look for

$recursive

bool

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

Returns

boolwhether page is in container

Returns true if container contains any pages

hasPages(bool $onlyVisible) : bool

Parameters

$onlyVisible

bool

whether to check only visible pages

Returns

boolwhether container has any pages

Returns hash code of current page

key() : string

Implements RecursiveIterator interface.

Returns

stringhash code of current page

Notifies container that the order of pages are updated

notifyOrderUpdated() : void

Removes the given page from the container

removePage(\Zend\Navigation\Page\AbstractPage | int $page, bool $recursive) : bool

Parameters

$page

\Zend\Navigation\Page\AbstractPageint

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

$recursive

bool

[optional] whether to remove recursively

Returns

boolwhether the removal was successful

Removes all pages in container

removePages() : \Zend\Navigation\self

Returns

\Zend\Navigation\selffluent 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\self

Parameters

$pages

array

pages to set

Returns

\Zend\Navigation\selffluent interface, returns self

Returns an array representation of all pages in container

toArray() : array

Returns

array

Checks if container index is valid

valid() : bool

Implements RecursiveIterator interface.

Returns

bool

Sorts the page index according to page order

sort() : void

 Properties

 

Whether index is dirty and needs to be re-arranged

$dirtyIndex : bool

 

An index that contains the order in which to iterate pages

$index : array

 

Contains sub pages

$pages : array