Source of file AbstractPage.php
Size: 36,230 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Navigation/Page/AbstractPage.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Navigation\Page; use Traversable; use Zend\Navigation\AbstractContainer; use Zend\Navigation\Exception; use Zend\Permissions\Acl\Resource\ResourceInterface as AclResource; use Zend\Stdlib\ArrayUtils; /** * Base class for Zend\Navigation\Page pages */ abstract class AbstractPage extends AbstractContainer { /** * Page label * * @var string|null */ protected $label; /** * Fragment identifier (anchor identifier) * * The fragment identifier (anchor identifier) pointing to an anchor within * a resource that is subordinate to another, primary resource. * The fragment identifier introduced by a hash mark "#". * Example: http://www.example.org/foo.html#bar ("bar" is the fragment identifier) * * @link http://www.w3.org/TR/html401/intro/intro.html#fragment-uri * * @var string|null */ protected $fragment; /** * Page id * * @var string|null */ protected $id; /** * Style class for this page (CSS) * * @var string|null */ protected $class; /** * A more descriptive title for this page * * @var string|null */ protected $title; /** * This page's target * * @var string|null */ protected $target; /** * Forward links to other pages * * @link http://www.w3.org/TR/html4/struct/links.html#h-12.3.1 * * @var array */ protected $rel = array(); /** * Reverse links to other pages * * @link http://www.w3.org/TR/html4/struct/links.html#h-12.3.1 * * @var array */ protected $rev = array(); /** * Page order used by parent container * * @var int|null */ protected $order; /** * ACL resource associated with this page * * @var string|AclResource|null */ protected $resource; /** * ACL privilege associated with this page * * @var string|null */ protected $privilege; /** * Permission associated with this page * * @var mixed|null */ protected $permission; /** * Text domain for Translator * * @var string */ protected $textDomain; /** * Whether this page should be considered active * * @var bool */ protected $active = false; /** * Whether this page should be considered visible * * @var bool */ protected $visible = true; /** * Parent container * * @var \Zend\Navigation\AbstractContainer|null */ protected $parent; /** * Custom page properties, used by __set(), __get() and __isset() * * @var array */ protected $properties = array(); /** * Static factories list for factory pages * * @var array */ protected static $factories = array(); // Initialization: /** * 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: * - If $options contains either of the keys 'action', 'controller', * or 'route', a Zend\Navigation\Page\Mvc page will be created. * - If $options contains the key 'uri', a Zend\Navigation\Page\Uri page * will be created. * * @param array|Traversable $options options used for creating page * @return AbstractPage a page instance * @throws Exception\InvalidArgumentException if $options is not * array/Traversable * @throws Exception\InvalidArgumentException if 'type' is specified * but class not found * @throws Exception\InvalidArgumentException if something goes wrong * during instantiation of * the page * @throws Exception\InvalidArgumentException if 'type' is given, and * the specified type does * not extend this class * @throws Exception\InvalidArgumentException if unable to determine * which class to instantiate */ public static function factory($options) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } if (!is_array($options)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $options must be an array or Traversable' ); } if (isset($options['type'])) { $type = $options['type']; if (is_string($type) && !empty($type)) { switch (strtolower($type)) { case 'mvc': $type = 'Zend\Navigation\Page\Mvc'; break; case 'uri': $type = 'Zend\Navigation\Page\Uri'; break; } if (!class_exists($type, true)) { throw new Exception\InvalidArgumentException( 'Cannot find class ' . $type ); } $page = new $type($options); if (!$page instanceof self) { throw new Exception\InvalidArgumentException( sprintf( 'Invalid argument: Detected type "%s", which ' . 'is not an instance of Zend\Navigation\Page', $type ) ); } return $page; } } if (static::$factories) { foreach (static::$factories as $factoryCallBack) { if (($page = call_user_func($factoryCallBack, $options))) { return $page; } } } $hasUri = isset($options['uri']); $hasMvc = isset($options['action']) || isset($options['controller']) || isset($options['route']); if ($hasMvc) { return new Mvc($options); } elseif ($hasUri) { return new Uri($options); } else { throw new Exception\InvalidArgumentException( 'Invalid argument: Unable to determine class to instantiate' ); } } /** * Add static factory for self::factory function * * @param type $callback Any callable variable */ public static function addFactory($callback) { static::$factories[] = $callback; } /** * Page constructor * * @param array|Traversable $options [optional] page options. Default is * null, which should set defaults. * @throws Exception\InvalidArgumentException if invalid options are given */ public function __construct($options = null) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } if (is_array($options)) { $this->setOptions($options); } // do custom initialization $this->init(); } /** * Initializes page (used by subclasses) * * @return void */ protected function init() { } /** * 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(). * * @param array $options associative array of options to set * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if invalid options are given */ public function setOptions(array $options) { foreach ($options as $key => $value) { $this->set($key, $value); } return $this; } // Accessors: /** * Sets page label * * @param string $label new page label * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if empty/no string is given */ public function setLabel($label) { if (null !== $label && !is_string($label)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $label must be a string or null' ); } $this->label = $label; return $this; } /** * Returns page label * * @return string page label or null */ public function getLabel() { return $this->label; } /** * Sets a fragment identifier * * @param string $fragment new fragment identifier * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if empty/no string is given */ public function setFragment($fragment) { if (null !== $fragment && !is_string($fragment)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $fragment must be a string or null' ); } $this->fragment = $fragment; return $this; } /** * Returns fragment identifier * * @return string|null fragment identifier */ public function getFragment() { return $this->fragment; } /** * Sets page id * * @param string|null $id [optional] id to set. Default is null, * which sets no id. * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if not given string or null */ public function setId($id = null) { if (null !== $id && !is_string($id) && !is_numeric($id)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $id must be a string, number or null' ); } $this->id = null === $id ? $id : (string) $id; return $this; } /** * Returns page id * * @return string|null page id or null */ public function getId() { return $this->id; } /** * Sets page CSS class * * @param string|null $class [optional] CSS class to set. Default * is null, which sets no CSS class. * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if not given string or null */ public function setClass($class = null) { if (null !== $class && !is_string($class)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $class must be a string or null' ); } $this->class = $class; return $this; } /** * Returns page class (CSS) * * @return string|null page's CSS class or null */ public function getClass() { return $this->class; } /** * Sets page title * * @param string $title [optional] page title. Default is * null, which sets no title. * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if not given string or null */ public function setTitle($title = null) { if (null !== $title && !is_string($title)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $title must be a non-empty string' ); } $this->title = $title; return $this; } /** * Returns page title * * @return string|null page title or null */ public function getTitle() { return $this->title; } /** * Sets page target * * @param string|null $target [optional] target to set. Default is * null, which sets no target. * * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if target is not string or null */ public function setTarget($target = null) { if (null !== $target && !is_string($target)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $target must be a string or null' ); } $this->target = $target; return $this; } /** * Returns page target * * @return string|null page target or null */ public function getTarget() { return $this->target; } /** * 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. * * @param array|Traversable $relations [optional] an associative array of * forward links to other pages * @throws Exception\InvalidArgumentException if $relations is not an array * or Traversable object * @return AbstractPage fluent interface, returns self */ public function setRel($relations = null) { $this->rel = array(); if (null !== $relations) { if ($relations instanceof Traversable) { $relations = ArrayUtils::iteratorToArray($relations); } if (!is_array($relations)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $relations must be an ' . 'array or an instance of Traversable' ); } foreach ($relations as $name => $relation) { if (is_string($name)) { $this->rel[$name] = $relation; } } } return $this; } /** * 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. * * @param string $relation [optional] name of relation to return. If not * given, all relations will be returned. * @return array an array of relations. If $relation is not * specified, all relations will be returned in * an associative array. */ public function getRel($relation = null) { if (null !== $relation) { return isset($this->rel[$relation]) ? $this->rel[$relation] : null; } return $this->rel; } /** * 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. * * @param array|Traversable $relations [optional] an associative array of * reverse links to other pages * * @throws Exception\InvalidArgumentException if $relations it not an array * or Traversable object * @return AbstractPage fluent interface, returns self */ public function setRev($relations = null) { $this->rev = array(); if (null !== $relations) { if ($relations instanceof Traversable) { $relations = ArrayUtils::iteratorToArray($relations); } if (!is_array($relations)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $relations must be an ' . 'array or an instance of Traversable' ); } foreach ($relations as $name => $relation) { if (is_string($name)) { $this->rev[$name] = $relation; } } } return $this; } /** * 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. * * @param string $relation [optional] name of relation to return. If not * given, all relations will be returned. * * @return array an array of relations. If $relation is not * specified, all relations will be returned in * an associative array. */ public function getRev($relation = null) { if (null !== $relation) { return isset($this->rev[$relation]) ? $this->rev[$relation] : null; } return $this->rev; } /** * Sets page order to use in parent container * * @param int $order [optional] page order in container. * Default is null, which sets no * specific order. * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if order is not integer or null */ public function setOrder($order = null) { if (is_string($order)) { $temp = (int) $order; if ($temp < 0 || $temp > 0 || $order == '0') { $order = $temp; } } if (null !== $order && !is_int($order)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $order must be an integer or null, ' . 'or a string that casts to an integer' ); } $this->order = $order; // notify parent, if any if (isset($this->parent)) { $this->parent->notifyOrderUpdated(); } return $this; } /** * Returns page order used in parent container * * @return int|null page order or null */ public function getOrder() { return $this->order; } /** * Sets ACL resource associated with this page * * @param string|AclResource $resource [optional] resource to associate * with page. Default is null, which * sets no resource. * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if $resource is invalid */ public function setResource($resource = null) { if (null === $resource || is_string($resource) || $resource instanceof AclResource ) { $this->resource = $resource; } else { throw new Exception\InvalidArgumentException( 'Invalid argument: $resource must be null, a string, ' . 'or an instance of Zend\Permissions\Acl\Resource\ResourceInterface' ); } return $this; } /** * Returns ACL resource associated with this page * * @return string|AclResource|null ACL resource or null */ public function getResource() { return $this->resource; } /** * Sets ACL privilege associated with this page * * @param string|null $privilege [optional] ACL privilege to associate * with this page. Default is null, which * sets no privilege. * * @return AbstractPage fluent interface, returns self */ public function setPrivilege($privilege = null) { $this->privilege = is_string($privilege) ? $privilege : null; return $this; } /** * Returns ACL privilege associated with this page * * @return string|null ACL privilege or null */ public function getPrivilege() { return $this->privilege; } /** * Sets permission associated with this page * * @param mixed|null $permission [optional] permission to associate * with this page. Default is null, which * sets no permission. * * @return AbstractPage fluent interface, returns self */ public function setPermission($permission = null) { $this->permission = $permission; return $this; } /** * Returns permission associated with this page * * @return mixed|null permission or null */ public function getPermission() { return $this->permission; } /** * Sets text domain for translation * * @param string|null $textDomain [optional] text domain to associate * with this page. Default is null, which * sets no text domain. * * @return AbstractPage fluent interface, returns self */ public function setTextDomain($textDomain = null) { if (null !== $textDomain) { $this->textDomain = $textDomain; } return $this; } /** * Returns text domain for translation * * @return mixed|null text domain or null */ public function getTextDomain() { return $this->textDomain; } /** * Sets whether page should be considered active or not * * @param bool $active [optional] whether page should be * considered active or not. Default is true. * * @return AbstractPage fluent interface, returns self */ public function setActive($active = true) { $this->active = (bool) $active; return $this; } /** * Returns whether page should be considered active or not * * @param bool $recursive [optional] whether page should be considered * active if any child pages are active. Default is * false. * @return bool whether page should be considered active */ public function isActive($recursive = false) { if (!$this->active && $recursive) { foreach ($this->pages as $page) { if ($page->isActive(true)) { return true; } } return false; } return $this->active; } /** * Proxy to isActive() * * @param bool $recursive [optional] whether page should be considered * active if any child pages are active. Default * is false. * * @return bool whether page should be considered active */ public function getActive($recursive = false) { return $this->isActive($recursive); } /** * Sets whether the page should be visible or not * * @param bool $visible [optional] whether page should be * considered visible or not. Default is true. * @return AbstractPage fluent interface, returns self */ public function setVisible($visible = true) { if (is_string($visible) && 'false' == strtolower($visible)) { $visible = false; } $this->visible = (bool) $visible; return $this; } /** * Returns a boolean value indicating whether the page is visible * * @param bool $recursive [optional] whether page should be considered * invisible if parent is invisible. Default is * false. * * @return bool whether page should be considered visible */ public function isVisible($recursive = false) { if ($recursive && isset($this->parent) && $this->parent instanceof self ) { if (!$this->parent->isVisible(true)) { return false; } } return $this->visible; } /** * Proxy to isVisible() * * Returns a boolean value indicating whether the page is visible * * @param bool $recursive [optional] whether page should be considered * invisible if parent is invisible. Default is * false. * * @return bool whether page should be considered visible */ public function getVisible($recursive = false) { return $this->isVisible($recursive); } /** * Sets parent container * * @param AbstractContainer $parent [optional] new parent to set. * Default is null which will set no parent. * @throws Exception\InvalidArgumentException * @return AbstractPage fluent interface, returns self */ public function setParent(AbstractContainer $parent = null) { if ($parent === $this) { throw new Exception\InvalidArgumentException( 'A page cannot have itself as a parent' ); } // return if the given parent already is parent if ($parent === $this->parent) { return $this; } // remove from old parent if (null !== $this->parent) { $this->parent->removePage($this); } // set new parent $this->parent = $parent; // add to parent if page and not already a child if (null !== $this->parent && !$this->parent->hasPage($this, false)) { $this->parent->addPage($this); } return $this; } /** * Returns parent container * * @return AbstractContainer|null parent container or null */ public function getParent() { return $this->parent; } /** * 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. * * @param string $property property name * @param mixed $value value to set * @return AbstractPage fluent interface, returns self * @throws Exception\InvalidArgumentException if property name is invalid */ public function set($property, $value) { if (!is_string($property) || empty($property)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $property must be a non-empty string' ); } $method = 'set' . static::normalizePropertyName($property); if ($method != 'setOptions' && method_exists($this, $method) ) { $this->$method($value); } else { $this->properties[$property] = $value; } return $this; } /** * 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. * * @param string $property property name * @return mixed the property's value or null * @throws Exception\InvalidArgumentException if property name is invalid */ public function get($property) { if (!is_string($property) || empty($property)) { throw new Exception\InvalidArgumentException( 'Invalid argument: $property must be a non-empty string' ); } $method = 'get' . static::normalizePropertyName($property); if (method_exists($this, $method)) { return $this->$method(); } elseif (isset($this->properties[$property])) { return $this->properties[$property]; } return null; } // Magic overloads: /** * Sets a custom property * * Magic overload for enabling <code>$page->propname = $value</code>. * * @param string $name property name * @param mixed $value value to set * @return void * @throws Exception\InvalidArgumentException if property name is invalid */ public function __set($name, $value) { $this->set($name, $value); } /** * Returns a property, or null if it doesn't exist * * Magic overload for enabling <code>$page->propname</code>. * * @param string $name property name * @return mixed property value or null * @throws Exception\InvalidArgumentException if property name is invalid */ public function __get($name) { return $this->get($name); } /** * Checks if a property is set * * Magic overload for enabling <code>isset($page->propname)</code>. * * 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). * * @param string $name property name * @return bool whether the given property exists */ public function __isset($name) { $method = 'get' . static::normalizePropertyName($name); if (method_exists($this, $method)) { return true; } return isset($this->properties[$name]); } /** * Unsets the given custom property * * Magic overload for enabling <code>unset($page->propname)</code>. * * @param string $name property name * @return void * @throws Exception\InvalidArgumentException if the property is native */ public function __unset($name) { $method = 'set' . static::normalizePropertyName($name); if (method_exists($this, $method)) { throw new Exception\InvalidArgumentException( sprintf( 'Unsetting native property "%s" is not allowed', $name ) ); } if (isset($this->properties[$name])) { unset($this->properties[$name]); } } /** * Returns page label * * Magic overload for enabling <code>echo $page</code>. * * @return string page label */ public function __toString() { return $this->label; } // Public methods: /** * Adds a forward relation to the page * * @param string $relation relation name (e.g. alternate, glossary, * canonical, etc) * @param mixed $value value to set for relation * @return AbstractPage fluent interface, returns self */ public function addRel($relation, $value) { if (is_string($relation)) { $this->rel[$relation] = $value; } return $this; } /** * Adds a reverse relation to the page * * @param string $relation relation name (e.g. alternate, glossary, * canonical, etc) * @param mixed $value value to set for relation * @return AbstractPage fluent interface, returns self */ public function addRev($relation, $value) { if (is_string($relation)) { $this->rev[$relation] = $value; } return $this; } /** * Removes a forward relation from the page * * @param string $relation name of relation to remove * @return AbstractPage fluent interface, returns self */ public function removeRel($relation) { if (isset($this->rel[$relation])) { unset($this->rel[$relation]); } return $this; } /** * Removes a reverse relation from the page * * @param string $relation name of relation to remove * @return AbstractPage fluent interface, returns self */ public function removeRev($relation) { if (isset($this->rev[$relation])) { unset($this->rev[$relation]); } return $this; } /** * Returns an array containing the defined forward relations * * @return array defined forward relations */ public function getDefinedRel() { return array_keys($this->rel); } /** * Returns an array containing the defined reverse relations * * @return array defined reverse relations */ public function getDefinedRev() { return array_keys($this->rev); } /** * Returns custom properties as an array * * @return array an array containing custom properties */ public function getCustomProperties() { return $this->properties; } /** * Returns a hash code value for the page * * @return string a hash code value for this page */ final public function hashCode() { return spl_object_hash($this); } /** * Returns an array representation of the page * * @return array associative array containing all page properties */ public function toArray() { return array_merge($this->getCustomProperties(), array( 'label' => $this->getLabel(), 'fragment' => $this->getFragment(), 'id' => $this->getId(), 'class' => $this->getClass(), 'title' => $this->getTitle(), 'target' => $this->getTarget(), 'rel' => $this->getRel(), 'rev' => $this->getRev(), 'order' => $this->getOrder(), 'resource' => $this->getResource(), 'privilege' => $this->getPrivilege(), 'permission' => $this->getPermission(), 'active' => $this->isActive(), 'visible' => $this->isVisible(), 'type' => get_class($this), 'pages' => parent::toArray(), )); } // Internal methods: /** * Normalizes a property name * * @param string $property property name to normalize * @return string normalized property name */ protected static function normalizePropertyName($property) { return str_replace(' ', '', ucwords(str_replace('_', ' ', $property))); } // Abstract methods: /** * Returns href for this page * * @return string the page's href */ abstract public function getHref(); } |