Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Navigation_Container Class Reference

Public Member Functions

 notifyOrderUpdated ()
 Notifies container that the order of pages are updated.
 
 addPage ($page)
 Adds a page to the container.
 
 addPages ($pages)
 Adds several pages at once.
 
 setPages (array $pages)
 Sets pages this container should have, removing existing pages.
 
 getPages ()
 Returns pages in the container.
 
 removePage ($page)
 Removes the given page from the container.
 
 removePages ()
 Removes all pages in container.
 
 hasPage (Zend_Navigation_Page $page, $recursive=false)
 Checks if the container has the given page.
 
 hasPages ()
 Returns true if container contains any pages.
 
 findOneBy ($property, $value, $useRegex=false)
 Returns a child page matching $property == $value or preg_match($value, $property), or null if not found.
 
 findAllBy ($property, $value, $useRegex=false)
 Returns all child pages matching $property == $value or preg_match($value, $property), or an empty array if no pages are found.
 
 findBy ($property, $value, $all=false, $useRegex=false)
 Returns page(s) matching $property == $value or preg_match($value, $property)
 
 __call ($method, $arguments)
 Magic overload: Proxy calls to finder methods.
 
 toArray ()
 Returns an array representation of all pages in container.
 
 current ()
 Returns current page.
 
 key ()
 Returns hash code of current page.
 
 next ()
 Moves index pointer to next page in the container.
 
 rewind ()
 Sets index pointer to first page in the container.
 
 valid ()
 Checks if container index is valid.
 
 hasChildren ()
 Proxy to hasPages()
 
 getChildren ()
 Returns the child container.
 
 count ()
 Returns number of pages in container.
 

Protected Member Functions

 _sort ()
 Sorts the page index according to page order.
 

Protected Attributes

 $_pages = array()
 
 $_index = array()
 
 $_dirtyIndex = false
 

Member Function Documentation

__call (   $method,
  $arguments 
)

Magic overload: Proxy calls to finder methods.

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

Parameters
string$methodmethod name
array$argumentsmethod arguments
Returns
mixed Zend_Navigation|array|null matching page, array of pages or null
Exceptions
Zend_Navigation_Exceptionif method does not exist
_sort ( )
protected

Sorts the page index according to page order.

Returns
void
addPage (   $page)

Adds a page to the container.

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

Parameters
Zend_Navigation_Page | array | Zend_Config$pagepage to add
Returns
Zend_Navigation_Container fluent interface, returns self
Exceptions
Zend_Navigation_Exceptionif page is invalid
addPages (   $pages)

Adds several pages at once.

Parameters
array | Zend_Config | Zend_Navigation_Container$pagespages to add
Returns
Zend_Navigation_Container fluent interface, returns self
Exceptions
Zend_Navigation_Exceptionif $pages is not array, Zend_Config or Zend_Navigation_Container
count ( )

Returns number of pages in container.

Implements Countable interface.

Returns
int number of pages in the container
current ( )

Returns current page.

Implements RecursiveIterator interface.

Returns
Zend_Navigation_Page current page or null
Exceptions
Zend_Navigation_Exceptionif the index is invalid
findAllBy (   $property,
  $value,
  $useRegex = false 
)

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

Parameters
string$propertyname of property to match against
mixed$valuevalue to match property against
bool$useRegex[optional] if true PHP's preg_match is used. Default is false.
Returns
array array containing only Zend_Navigation_Page instances
findBy (   $property,
  $value,
  $all = false,
  $useRegex = false 
)

Returns page(s) matching $property == $value or preg_match($value, $property)

Parameters
string$propertyname of property to match against
mixed$valuevalue to match property against
bool$all[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.
bool$useRegex[optional] if true PHP's preg_match is used. Default is false.
Returns
Zend_Navigation_Page|null matching page or null
findOneBy (   $property,
  $value,
  $useRegex = false 
)

Returns a child page matching $property == $value or preg_match($value, $property), or null if not found.

Parameters
string$propertyname of property to match against
mixed$valuevalue to match property against
bool$useRegex[optional] if true PHP's preg_match is used. Default is false.
Returns
Zend_Navigation_Page|null matching page or null
getChildren ( )

Returns the child container.

Implements RecursiveIterator interface.

Returns
Zend_Navigation_Page|null
getPages ( )

Returns pages in the container.

Returns
array array of Zend_Navigation_Page instances
hasChildren ( )

Proxy to hasPages()

Implements RecursiveIterator interface.

Returns
bool whether container has any pages
hasPage ( Zend_Navigation_Page  $page,
  $recursive = false 
)

Checks if the container has the given page.

Parameters
Zend_Navigation_Page$pagepage to look for
bool$recursive[optional] whether to search recursively. Default is false.
Returns
bool whether page is in container
hasPages ( )

Returns true if container contains any pages.

Returns
bool whether container has any pages
key ( )

Returns hash code of current page.

Implements RecursiveIterator interface.

Returns
string hash code of current page
next ( )

Moves index pointer to next page in the container.

Implements RecursiveIterator interface.

Returns
void
notifyOrderUpdated ( )

Notifies container that the order of pages are updated.

Returns
void
removePage (   $page)

Removes the given page from the container.

Parameters
Zend_Navigation_Page | int$pagepage to remove, either a page instance or a specific page order
Returns
bool whether the removal was successful
removePages ( )

Removes all pages in container.

Returns
Zend_Navigation_Container fluent interface, returns self
rewind ( )

Sets index pointer to first page in the container.

Implements RecursiveIterator interface.

Returns
void
setPages ( array  $pages)

Sets pages this container should have, removing existing pages.

Parameters
array$pagespages to set
Returns
Zend_Navigation_Container fluent interface, returns self
toArray ( )

Returns an array representation of all pages in container.

Returns
array
valid ( )

Checks if container index is valid.

Implements RecursiveIterator interface.

Returns
bool

Member Data Documentation

$_dirtyIndex = false
protected
$_index = array()
protected
$_pages = array()
protected