Class Mvc

Summary

Fully Qualified Name: Zend\Navigation\Page\Mvc
Extends: AbstractPage

Description

Represents a page that is defined using controller, action, route name and route params to assemble the href

The two constants defined were originally provided via the zend-mvc class ModuleRouteListener; to remove the requirement on that component, they are reproduced here.

Methods

Name Description Defined By
__call() Magic overload: Proxy calls to finder methods AbstractContainer
__construct() Page constructor AbstractPage
__get() Returns a property, or null if it doesn't exist AbstractPage
__isset() Checks if a property is set AbstractPage
__set() Sets a custom property AbstractPage
__toString() Returns page label AbstractPage
__unset() Unsets the given custom property AbstractPage
addFactory() Add static factory for self::factory function AbstractPage
addPage() Adds a page to the container AbstractContainer
addPages() Adds several pages at once AbstractContainer
addRel() Adds a forward relation to the page AbstractPage
addRev() Adds a reverse relation to the page AbstractPage
count() Returns number of pages in container AbstractContainer
current() Returns current page AbstractContainer
factory() Factory for Zend\Navigation\Page classes AbstractPage
findAllBy() Returns all child pages matching $property == $value, or an empty array if no pages are found AbstractContainer
findBy() Returns page(s) matching $property == $value AbstractContainer
findOneBy() Returns a child page matching $property == $value, or null if not found AbstractContainer
get() Returns the value of the given property AbstractPage
getAction() Returns action name to use when assembling URL Mvc
getActive() Proxy to isActive() AbstractPage
getChildren() Returns the child container. AbstractContainer
getClass() Returns page class (CSS) AbstractPage
getController() Returns controller name to use when assembling URL Mvc
getCustomProperties() Returns custom properties as an array AbstractPage
getDefaultRoute() Get default route name Mvc
getDefaultRouter() Gets the default router for assembling URLs. Mvc
getDefinedRel() Returns an array containing the defined forward relations AbstractPage
getDefinedRev() Returns an array containing the defined reverse relations AbstractPage
getFragment() Returns fragment identifier AbstractPage
getHref() Returns href for this page Mvc
getId() Returns page id AbstractPage
getLabel() Returns page label AbstractPage
getOrder() Returns page order used in parent container AbstractPage
getPages() Returns pages in the container AbstractContainer
getParams() Returns params to use when assembling URL Mvc
getParent() Returns parent container AbstractPage
getPermission() Returns permission associated with this page AbstractPage
getPrivilege() Returns ACL privilege associated with this page AbstractPage
getQuery() Returns URL query part to use when assembling URL Mvc
getRel() Returns the page's forward links to other pages AbstractPage
getResource() Returns ACL resource associated with this page AbstractPage
getRev() Returns the page's reverse links to other pages AbstractPage
getRoute() Returns route name to use when assembling URL Mvc
getRouteMatch() Get the route match. Mvc
getRouter() Get the router. Mvc
getTarget() Returns page target AbstractPage
getTextDomain() Returns text domain for translation AbstractPage
getTitle() Returns page title AbstractPage
getVisible() Proxy to isVisible() AbstractPage
hasChildren() Proxy to hasPages() AbstractContainer
hasPage() Checks if the container has the given page AbstractContainer
hasPages() Returns true if container contains any pages AbstractContainer
hashCode() Returns a hash code value for the page AbstractPage
isActive() Returns whether page should be considered active or not Mvc
isVisible() Returns a boolean value indicating whether the page is visible AbstractPage
key() Returns hash code of current page AbstractContainer
next() Moves index pointer to next page in the container AbstractContainer
notifyOrderUpdated() Notifies container that the order of pages are updated AbstractContainer
removePage() Removes the given page from the container AbstractContainer
removePages() Removes all pages in container AbstractContainer
removeRel() Removes a forward relation from the page AbstractPage
removeRev() Removes a reverse relation from the page AbstractPage
rewind() Sets index pointer to first page in the container AbstractContainer
set() Sets the given property AbstractPage
setAction() Sets action name to use when assembling URL Mvc
setActive() Sets whether page should be considered active or not AbstractPage
setClass() Sets page CSS class AbstractPage
setController() Sets controller name to use when assembling URL Mvc
setDefaultRoute() Set default route name Mvc
setDefaultRouter() Sets the default router for assembling URLs. Mvc
setFragment() Sets a fragment identifier AbstractPage
setId() Sets page id AbstractPage
setLabel() Sets page label AbstractPage
setOptions() Sets page properties using options from an associative array AbstractPage
setOrder() Sets page order to use in parent container AbstractPage
setPages() Sets pages this container should have, removing existing pages AbstractContainer
setParams() Sets params to use when assembling URL Mvc
setParent() Sets parent container AbstractPage
setPermission() Sets permission associated with this page AbstractPage
setPrivilege() Sets ACL privilege associated with this page AbstractPage
setQuery() Sets URL query part to use when assembling URL Mvc
setRel() Sets the page's forward links to other pages AbstractPage
setResource() Sets ACL resource associated with this page AbstractPage
setRev() Sets the page's reverse links to other pages AbstractPage
setRoute() Sets route name to use when assembling URL Mvc
setRouteMatch() Set route match object from which parameters will be retrieved Mvc
setRouter() Sets router for assembling URLs Mvc
setTarget() Sets page target AbstractPage
setTextDomain() Sets text domain for translation AbstractPage
setTitle() Sets page title AbstractPage
setUseRouteMatch() Set whether the page should use route match params for assembling link uri Mvc
setVisible() Sets whether the page should be visible or not AbstractPage
toArray() Returns an array representation of the page Mvc
useRouteMatch() Get the useRouteMatch flag Mvc
valid() Checks if container index is valid AbstractContainer

Method Details

__call()

Magic overload: Proxy calls to finder methods

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');

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

Returns:

__construct()

Page constructor

Parameter Name Type Description
$options array|\Traversable [optional]

Returns:

__get()

Returns a property, or null if it doesn't exist

Magic overload for enabling $page->propname.

Parameter Name Type Description
$name string property

Returns: mixed property value or null

__isset()

Checks if a property is set

Magic overload for enabling isset($page->propname).

Returns true if the property is native (id, class, title, etc), and true or false if it's a custom property (depending on whether the property actually is set).

Parameter Name Type Description
$name string property

Returns: bool whether the given property exists

__set()

Sets a custom property

Magic overload for enabling $page->propname = $value.

Parameter Name Type Description
$name string property
$value mixed value

Returns: void

__toString()

Returns page label

Magic overload for enabling echo $page.

Returns: string page label

__unset()

Unsets the given custom property

Magic overload for enabling unset($page->propname).

Parameter Name Type Description
$name string property

Returns: void

addFactory()

Add static factory for self::factory function

Parameter Name Type Description
$callback callable Any

Returns:

addPage()

Adds a page to the container

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

Parameter Name Type Description
$page \Page\AbstractPage|array|\Traversable page

Returns: self fluent interface, returns self

addPages()

Adds several pages at once

Parameter Name Type Description
$pages array|\Traversable|\AbstractContainer pages

Returns: self fluent interface, returns self

addRel()

Adds a forward relation to the page

Parameter Name Type Description
$relation string relation
$value mixed value

Returns: \AbstractPage fluent interface, returns self

addRev()

Adds a reverse relation to the page

Parameter Name Type Description
$relation string relation
$value mixed value

Returns: \AbstractPage fluent interface, returns self

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: \Page\AbstractPage current page or null

factory()

Factory for Zend\Navigation\Page classes

A specific type to construct can be specified by specifying the key 'type' in $options. If type is 'uri' or 'mvc', the type will be resolved to Zend\Navigation\Page\Uri or Zend\Navigation\Page\Mvc. Any other value for 'type' will be considered the full name of the class to construct. A valid custom page class must extend Zend\Navigation\Page\AbstractPage.

If 'type' is not given, the type of page to construct will be determined by the following rules:

Parameter Name Type Description
$options array|\Traversable options

Returns: \AbstractPage a page instance

findAllBy()

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

Parameter Name Type Description
$property string name
$value mixed value

Returns: array array containing only Page\AbstractPage instances

findBy()

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

Parameter Name Type Description
$property string name
$value mixed value
$all bool [optional]

Returns: \Page\AbstractPage|null matching page or null

findOneBy()

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

Parameter Name Type Description
$property string name
$value mixed value

Returns: \Page\AbstractPage|null matching page or null

get()

Returns the value of the given property

If the given property is native (id, class, title, etc), the matching get method will be used. Otherwise, it will return the matching custom property, or null if not found.

Parameter Name Type Description
$property string property

Returns: mixed the property's value or null

getAction()

Returns action name to use when assembling URL

Returns: string|null action name

getActive()

Proxy to isActive()

Parameter Name Type Description
$recursive bool [optional]

Returns: bool whether page should be considered active

getChildren()

Returns the child container.

Implements RecursiveIterator interface.

Returns: \Page\AbstractPage|null

getClass()

Returns page class (CSS)

Returns: string|null page's CSS class or null

getController()

Returns controller name to use when assembling URL

Returns: string|null controller name or null

getCustomProperties()

Returns custom properties as an array

Returns: array an array containing custom properties

getDefaultRoute()

Get default route name

Returns: string

getDefaultRouter()

Gets the default router for assembling URLs.

Returns: \RouteStackInterface

getDefinedRel()

Returns an array containing the defined forward relations

Returns: array defined forward relations

getDefinedRev()

Returns an array containing the defined reverse relations

Returns: array defined reverse relations

getFragment()

Returns fragment identifier

Returns: string|null fragment identifier

getHref()

Returns href for this page

This method uses {@link RouteStackInterface} to assemble the href based on the page's properties.

Returns: string page href

getId()

Returns page id

Returns: string|null page id or null

getLabel()

Returns page label

Returns: string page label or null

getOrder()

Returns page order used in parent container

Returns: int|null page order or null

getPages()

Returns pages in the container

Returns: array array of Page\AbstractPage instances

getParams()

Returns params to use when assembling URL

Returns: array page params

getParent()

Returns parent container

Returns: \AbstractContainer|null parent container or null

getPermission()

Returns permission associated with this page

Returns: mixed|null permission or null

getPrivilege()

Returns ACL privilege associated with this page

Returns: string|null ACL privilege or null

getQuery()

Returns URL query part to use when assembling URL

Returns: array|string|null URL query part (as an array or string) or null

getRel()

Returns the page's forward links to other pages

This method returns an associative array of forward links to other pages, where each element's key is the name of the relation (e.g. alternate, prev, next, help, etc), and the value is a mixed value that could somehow be considered a page.

Parameter Name Type Description
$relation string [optional]

Returns: array an array of relations. If $relation is not specified, all relations will be returned in an associative array.

getResource()

Returns ACL resource associated with this page

Returns: string|\AclResource|null ACL resource or null

getRev()

Returns the page's reverse links to other pages

This method returns an associative array of forward links to other pages, where each element's key is the name of the relation (e.g. alternate, prev, next, help, etc), and the value is a mixed value that could somehow be considered a page.

Parameter Name Type Description
$relation string [optional]

Returns: array an array of relations. If $relation is not specified, all relations will be returned in an associative array.

getRoute()

Returns route name to use when assembling URL

Returns: string route name

getRouteMatch()

Get the route match.

Returns: \RouteMatch

getRouter()

Get the router.

Returns: null|\RouteStackInterface|\MvcRouter\RouteStackInterface

getTarget()

Returns page target

Returns: string|null page target or null

getTextDomain()

Returns text domain for translation

Returns: mixed|null text domain or null

getTitle()

Returns page title

Returns: string|null page title or null

getVisible()

Proxy to isVisible()

Returns a boolean value indicating whether the page is visible

Parameter Name Type Description
$recursive bool [optional]

Returns: bool whether page should be considered visible

hasChildren()

Proxy to hasPages()

Implements RecursiveIterator interface.

Returns: bool whether container has any pages

hasPage()

Checks if the container has the given page

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

Returns: bool whether page is in container

hasPages()

Returns true if container contains any pages

Parameter Name Type Description
$onlyVisible bool whether

Returns: bool whether container has any pages

hashCode()

Returns a hash code value for the page

Returns: string a hash code value for this page

isActive()

Returns whether page should be considered active or not

This method will compare the page properties against the route matches composed in the object.

Parameter Name Type Description
$recursive bool [optional]

Returns: bool whether page should be considered active or not

isVisible()

Returns a boolean value indicating whether the page is visible

Parameter Name Type Description
$recursive bool [optional]

Returns: bool whether page should be considered visible

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()

Removes the given page from the container

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

Returns: bool whether the removal was successful

removePages()

Removes all pages in container

Returns: self fluent interface, returns self

removeRel()

Removes a forward relation from the page

Parameter Name Type Description
$relation string name

Returns: \AbstractPage fluent interface, returns self

removeRev()

Removes a reverse relation from the page

Parameter Name Type Description
$relation string name

Returns: \AbstractPage fluent interface, returns self

rewind()

Sets index pointer to first page in the container

Implements RecursiveIterator interface.

Returns: void

set()

Sets the given property

If the given property is native (id, class, title, etc), the matching set method will be used. Otherwise, it will be set as a custom property.

Parameter Name Type Description
$property string property
$value mixed value

Returns: \AbstractPage fluent interface, returns self

setAction()

Sets action name to use when assembling URL

Parameter Name Type Description
$action string action

Returns: \Mvc fluent interface, returns self

setActive()

Sets whether page should be considered active or not

Parameter Name Type Description
$active bool [optional]

Returns: \AbstractPage fluent interface, returns self

setClass()

Sets page CSS class

Parameter Name Type Description
$class string|null [optional]

Returns: \AbstractPage fluent interface, returns self

setController()

Sets controller name to use when assembling URL

Parameter Name Type Description
$controller string|null controller

Returns: \Mvc fluent interface, returns self

setDefaultRoute()

Set default route name

Parameter Name Type Description
$route string

Returns: void

setDefaultRouter()

Sets the default router for assembling URLs.

Parameter Name Type Description
$router \RouteStackInterface Router

Returns: void

setFragment()

Sets a fragment identifier

Parameter Name Type Description
$fragment string new

Returns: \AbstractPage fluent interface, returns self

setId()

Sets page id

Parameter Name Type Description
$id string|null [optional]

Returns: \AbstractPage fluent interface, returns self

setLabel()

Sets page label

Parameter Name Type Description
$label string new

Returns: \AbstractPage fluent interface, returns self

setOptions()

Sets page properties using options from an associative array

Each key in the array corresponds to the according set*() method, and each word is separated by underscores, e.g. the option 'target' corresponds to setTarget(), and the option 'reset_params' corresponds to the method setResetParams().

Parameter Name Type Description
$options array associative

Returns: \AbstractPage fluent interface, returns self

setOrder()

Sets page order to use in parent container

Parameter Name Type Description
$order int [optional]

Returns: \AbstractPage fluent interface, returns self

setPages()

Sets pages this container should have, removing existing pages

Parameter Name Type Description
$pages array pages

Returns: self fluent interface, returns self

setParams()

Sets params to use when assembling URL

Parameter Name Type Description
$params array|null [optional]

Returns: \Mvc fluent interface, returns self

setParent()

Sets parent container

Parameter Name Type Description
$parent \AbstractContainer [optional]

Returns: \AbstractPage fluent interface, returns self

setPermission()

Sets permission associated with this page

Parameter Name Type Description
$permission mixed|null [optional]

Returns: \AbstractPage fluent interface, returns self

setPrivilege()

Sets ACL privilege associated with this page

Parameter Name Type Description
$privilege string|null [optional]

Returns: \AbstractPage fluent interface, returns self

setQuery()

Sets URL query part to use when assembling URL

Parameter Name Type Description
$query array|string|null URL

Returns: self fluent interface, returns self

setRel()

Sets the page's forward links to other pages

This method expects an associative array of forward links to other pages, where each element's key is the name of the relation (e.g. alternate, prev, next, help, etc), and the value is a mixed value that could somehow be considered a page.

Parameter Name Type Description
$relations array|\Traversable [optional]

Returns: \AbstractPage fluent interface, returns self

setResource()

Sets ACL resource associated with this page

Parameter Name Type Description
$resource string|\AclResource [optional]

Returns: \AbstractPage fluent interface, returns self

setRev()

Sets the page's reverse links to other pages

This method expects an associative array of reverse links to other pages, where each element's key is the name of the relation (e.g. alternate, prev, next, help, etc), and the value is a mixed value that could somehow be considered a page.

Parameter Name Type Description
$relations array|\Traversable [optional]

Returns: \AbstractPage fluent interface, returns self

setRoute()

Sets route name to use when assembling URL

Parameter Name Type Description
$route string Route

Returns: \Mvc Fluent interface, returns self.

setRouteMatch()

Set route match object from which parameters will be retrieved

Parameter Name Type Description
$matches \RouteMatch|\MvcRouter\RouteMatch

Returns: \Mvc fluent interface, returns self

setRouter()

Sets router for assembling URLs

Parameter Name Type Description
$router \RouteStackInterface|\MvcRouter\RouteStackInterface Router

Returns: \Mvc Fluent interface, returns self

setTarget()

Sets page target

Parameter Name Type Description
$target string|null [optional]

Returns: \AbstractPage fluent interface, returns self

setTextDomain()

Sets text domain for translation

Parameter Name Type Description
$textDomain string|null [optional]

Returns: \AbstractPage fluent interface, returns self

setTitle()

Sets page title

Parameter Name Type Description
$title string [optional]

Returns: \AbstractPage fluent interface, returns self

setUseRouteMatch()

Set whether the page should use route match params for assembling link uri

Parameter Name Type Description
$useRouteMatch bool [optional]

Returns: \Mvc

setVisible()

Sets whether the page should be visible or not

Parameter Name Type Description
$visible bool [optional]

Returns: \AbstractPage fluent interface, returns self

toArray()

Returns an array representation of the page

Returns: array associative array containing all page properties

useRouteMatch()

Get the useRouteMatch flag

Returns: bool

valid()

Checks if container index is valid

Implements RecursiveIterator interface.

Returns: bool

Top