Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
AbstractPage Class Reference

Base class for Zend pages. More...

Public Member Functions

 __construct ($options=null)
 Page constructor.
 
 setOptions (array $options)
 Sets page properties using options from an associative array.
 
 setLabel ($label)
 Sets page label.
 
 getLabel ()
 Returns page label.
 
 setFragment ($fragment)
 Sets a fragment identifier.
 
 getFragment ()
 Returns fragment identifier.
 
 setId ($id=null)
 Sets page id.
 
 getId ()
 Returns page id.
 
 setClass ($class=null)
 Sets page CSS class.
 
 getClass ()
 Returns page class (CSS)
 
 setTitle ($title=null)
 Sets page title.
 
 getTitle ()
 Returns page title.
 
 setTarget ($target=null)
 Sets page target.
 
 getTarget ()
 Returns page target.
 
 setRel ($relations=null)
 Sets the page's forward links to other pages.
 
 getRel ($relation=null)
 Returns the page's forward links to other pages.
 
 setRev ($relations=null)
 Sets the page's reverse links to other pages.
 
 getRev ($relation=null)
 Returns the page's reverse links to other pages.
 
 setOrder ($order=null)
 Sets page order to use in parent container.
 
 getOrder ()
 Returns page order used in parent container.
 
 setResource ($resource=null)
 Sets ACL resource associated with this page.
 
 getResource ()
 Returns ACL resource associated with this page.
 
 setPrivilege ($privilege=null)
 Sets ACL privilege associated with this page.
 
 getPrivilege ()
 Returns ACL privilege associated with this page.
 
 setPermission ($permission=null)
 Sets permission associated with this page.
 
 getPermission ()
 Returns permission associated with this page.
 
 setTextDomain ($textDomain=null)
 Sets text domain for translation.
 
 getTextDomain ()
 Returns text domain for translation.
 
 setActive ($active=true)
 Sets whether page should be considered active or not.
 
 isActive ($recursive=false)
 Returns whether page should be considered active or not.
 
 getActive ($recursive=false)
 Proxy to isActive()
 
 setVisible ($visible=true)
 Sets whether the page should be visible or not.
 
 isVisible ($recursive=false)
 Returns a boolean value indicating whether the page is visible.
 
 getVisible ($recursive=false)
 Proxy to isVisible()
 
 setParent (AbstractContainer $parent=null)
 Sets parent container.
 
 getParent ()
 Returns parent container.
 
 set ($property, $value)
 Sets the given property.
 
 get ($property)
 Returns the value of the given property.
 
 __set ($name, $value)
 Sets a custom property.
 
 __get ($name)
 Returns a property, or null if it doesn't exist.
 
 __isset ($name)
 Checks if a property is set.
 
 __unset ($name)
 Unsets the given custom property.
 
 __toString ()
 Returns page label.
 
 addRel ($relation, $value)
 Adds a forward relation to the page.
 
 addRev ($relation, $value)
 Adds a reverse relation to the page.
 
 removeRel ($relation)
 Removes a forward relation from the page.
 
 removeRev ($relation)
 Removes a reverse relation from the page.
 
 getDefinedRel ()
 Returns an array containing the defined forward relations.
 
 getDefinedRev ()
 Returns an array containing the defined reverse relations.
 
 getCustomProperties ()
 Returns custom properties as an array.
 
 hashCode ()
 Returns a hash code value for the page.
 
 toArray ()
 Returns an array representation of the page.
 
 getHref ()
 Returns href for this page.
 
- Public Member Functions inherited from AbstractContainer
 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.
 
 removePages ()
 Removes all pages in container.
 
 hasPage (Page\AbstractPage $page, $recursive=false)
 Checks if the container has the given page.
 
 hasPages ($onlyVisible=false)
 Returns true if container contains any pages.
 
 findOneBy ($property, $value)
 Returns a child page matching $property == $value, or null if not found.
 
 findAllBy ($property, $value)
 Returns all child pages matching $property == $value, or an empty array if no pages are found.
 
 findBy ($property, $value, $all=false)
 Returns page(s) matching $property == $value.
 
 __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.
 

Static Public Member Functions

static factory ($options)
 Factory for Zend classes.
 
static addFactory ($callback)
 Add static factory for self::factory function.
 

Protected Member Functions

 init ()
 Initializes page (used by subclasses)
 
- Protected Member Functions inherited from AbstractContainer
 sort ()
 Sorts the page index according to page order.
 

Static Protected Member Functions

static normalizePropertyName ($property)
 Normalizes a property name.
 

Protected Attributes

 $label
 
 $fragment
 
 $id
 
 $class
 
 $title
 
 $target
 
 $rel = []
 
 $rev = []
 
 $order
 
 $resource
 
 $privilege
 
 $permission
 
 $textDomain
 
 $active = false
 
 $visible = true
 
 $parent
 
 $properties = []
 
- Protected Attributes inherited from AbstractContainer
 $pages = []
 
 $index = []
 
 $dirtyIndex = false
 

Static Protected Attributes

static $factories = []
 

Detailed Description

Base class for Zend pages.

Constructor & Destructor Documentation

__construct (   $options = null)

Page constructor.

Parameters
array | Traversable$options[optional] page options. Default is null, which should set defaults.
Exceptions
Exception\InvalidArgumentExceptionif invalid options are given

Member Function Documentation

__get (   $name)

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

Magic overload for enabling $page->propname.

Parameters
string$nameproperty name
Returns
mixed property value or null
Exceptions
Exception\InvalidArgumentExceptionif property name is invalid
__isset (   $name)

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

Parameters
string$nameproperty name
Returns
bool whether the given property exists
__set (   $name,
  $value 
)

Sets a custom property.

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

Parameters
string$nameproperty name
mixed$valuevalue to set
Returns
void
Exceptions
Exception\InvalidArgumentExceptionif property name is invalid
__toString ( )

Returns page label.

Magic overload for enabling echo $page.

Returns
string page label
__unset (   $name)

Unsets the given custom property.

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

Parameters
string$nameproperty name
Returns
void
Exceptions
Exception\InvalidArgumentExceptionif the property is native
static addFactory (   $callback)
static

Add static factory for self::factory function.

Parameters
callable$callbackAny callable variable
addRel (   $relation,
  $value 
)

Adds a forward relation to the page.

Parameters
string$relationrelation name (e.g. alternate, glossary, canonical, etc)
mixed$valuevalue to set for relation
Returns
AbstractPage fluent interface, returns self
addRev (   $relation,
  $value 
)

Adds a reverse relation to the page.

Parameters
string$relationrelation name (e.g. alternate, glossary, canonical, etc)
mixed$valuevalue to set for relation
Returns
AbstractPage fluent interface, returns self
static factory (   $options)
static

Factory for Zend 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 or Zend. Any other value for 'type' will be considered the full name of the class to construct. A valid custom page class must extend Zend.

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

  • If $options contains either of the keys 'action', 'controller', or 'route', a Zend page will be created.
  • If $options contains the key 'uri', a Zend page will be created.
Parameters
array | Traversable$optionsoptions used for creating page
Returns
AbstractPage a page instance
Exceptions
Exception\InvalidArgumentExceptionif $options is not array/Traversable
Exception\InvalidArgumentExceptionif 'type' is specified but class not found
Exception\InvalidArgumentExceptionif something goes wrong during instantiation of the page
Exception\InvalidArgumentExceptionif 'type' is given, and the specified type does not extend this class
Exception\InvalidArgumentExceptionif unable to determine which class to instantiate
get (   $property)

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.

Parameters
string$propertyproperty name
Returns
mixed the property's value or null
Exceptions
Exception\InvalidArgumentExceptionif property name is invalid
getActive (   $recursive = false)

Proxy to isActive()

Parameters
bool$recursive[optional] whether page should be considered active if any child pages are active. Default is false.
Returns
bool whether page should be considered active
getClass ( )

Returns page class (CSS)

Returns
string|null page's CSS class or null
getCustomProperties ( )

Returns custom properties as an array.

Returns
array an array containing custom properties
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 ( )
abstract

Returns href for this page.

Returns
string the page's 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
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
getRel (   $relation = null)

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.

Parameters
string$relation[optional] name of relation to return. If not given, all relations will be returned.
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 (   $relation = null)

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.

Parameters
string$relation[optional] name of relation to return. If not given, all relations will be returned.
Returns
array an array of relations. If $relation is not specified, all relations will be returned in an associative array.
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 (   $recursive = false)

Proxy to isVisible()

Returns a boolean value indicating whether the page is visible

Parameters
bool$recursive[optional] whether page should be considered invisible if parent is invisible. Default is false.
Returns
bool whether page should be considered visible
hashCode ( )
final

Returns a hash code value for the page.

Returns
string a hash code value for this page
init ( )
protected

Initializes page (used by subclasses)

Returns
void
isActive (   $recursive = false)

Returns whether page should be considered active or not.

Parameters
bool$recursive[optional] whether page should be considered active if any child pages are active. Default is false.
Returns
bool whether page should be considered active
isVisible (   $recursive = false)

Returns a boolean value indicating whether the page is visible.

Parameters
bool$recursive[optional] whether page should be considered invisible if parent is invisible. Default is false.
Returns
bool whether page should be considered visible
static normalizePropertyName (   $property)
staticprotected

Normalizes a property name.

Parameters
string$propertyproperty name to normalize
Returns
string normalized property name
removeRel (   $relation)

Removes a forward relation from the page.

Parameters
string$relationname of relation to remove
Returns
AbstractPage fluent interface, returns self
removeRev (   $relation)

Removes a reverse relation from the page.

Parameters
string$relationname of relation to remove
Returns
AbstractPage fluent interface, returns self
set (   $property,
  $value 
)

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.

Parameters
string$propertyproperty name
mixed$valuevalue to set
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif property name is invalid
setActive (   $active = true)

Sets whether page should be considered active or not.

Parameters
bool$active[optional] whether page should be considered active or not. Default is true.
Returns
AbstractPage fluent interface, returns self
setClass (   $class = null)

Sets page CSS class.

Parameters
string | null$class[optional] CSS class to set. Default is null, which sets no CSS class.
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif not given string or null
setFragment (   $fragment)

Sets a fragment identifier.

Parameters
string$fragmentnew fragment identifier
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif empty/no string is given
setId (   $id = null)

Sets page id.

Parameters
string | null$id[optional] id to set. Default is null, which sets no id.
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif not given string or null
setLabel (   $label)

Sets page label.

Parameters
string$labelnew page label
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif empty/no string is given
setOptions ( array  $options)

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

Parameters
array$optionsassociative array of options to set
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif invalid options are given
setOrder (   $order = null)

Sets page order to use in parent container.

Parameters
int$order[optional] page order in container. Default is null, which sets no specific order.
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif order is not integer or null
setParent ( AbstractContainer  $parent = null)

Sets parent container.

Parameters
AbstractContainer$parent[optional] new parent to set. Default is null which will set no parent.
Exceptions
Exception\InvalidArgumentException
Returns
AbstractPage fluent interface, returns self
setPermission (   $permission = null)

Sets permission associated with this page.

Parameters
mixed | null$permission[optional] permission to associate with this page. Default is null, which sets no permission.
Returns
AbstractPage fluent interface, returns self
setPrivilege (   $privilege = null)

Sets ACL privilege associated with this page.

Parameters
string | null$privilege[optional] ACL privilege to associate with this page. Default is null, which sets no privilege.
Returns
AbstractPage fluent interface, returns self
setRel (   $relations = null)

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.

Parameters
array | Traversable$relations[optional] an associative array of forward links to other pages
Exceptions
Exception\InvalidArgumentExceptionif $relations is not an array or Traversable object
Returns
AbstractPage fluent interface, returns self
setResource (   $resource = null)

Sets ACL resource associated with this page.

Parameters
string | AclResource$resource[optional] resource to associate with page. Default is null, which sets no resource.
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif $resource is invalid
setRev (   $relations = null)

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.

Parameters
array | Traversable$relations[optional] an associative array of reverse links to other pages
Exceptions
Exception\InvalidArgumentExceptionif $relations it not an array or Traversable object
Returns
AbstractPage fluent interface, returns self
setTarget (   $target = null)

Sets page target.

Parameters
string | null$target[optional] target to set. Default is null, which sets no target.
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif target is not string or null
setTextDomain (   $textDomain = null)

Sets text domain for translation.

Parameters
string | null$textDomain[optional] text domain to associate with this page. Default is null, which sets no text domain.
Returns
AbstractPage fluent interface, returns self
setTitle (   $title = null)

Sets page title.

Parameters
string$title[optional] page title. Default is null, which sets no title.
Returns
AbstractPage fluent interface, returns self
Exceptions
Exception\InvalidArgumentExceptionif not given string or null
setVisible (   $visible = true)

Sets whether the page should be visible or not.

Parameters
bool$visible[optional] whether page should be considered visible or not. Default is true.
Returns
AbstractPage fluent interface, returns self
toArray ( )

Returns an array representation of the page.

Returns
array associative array containing all page properties

Member Data Documentation

$active = false
protected
$class
protected
$factories = []
staticprotected
$fragment
protected
$id
protected
$label
protected
$order
protected
$parent
protected
$permission
protected
$privilege
protected
$properties = []
protected
$rel = []
protected
$resource
protected
$rev = []
protected
$target
protected
$textDomain
protected
$title
protected
$visible = true
protected