public function addPage($page) { if (is_array($page) || $page instanceof Config) { if (isset($page['route']) && !isset($page['type'])) { $page['type'] = "Bundle\\ZendNavigationBundle\\Page\\RouterPage"; } else { if (isset($page['uri']) && !isset($page['type'])) { $page['type'] = "Bundle\\ZendNavigationBundle\\Page\\UriPage"; } } $page = AbstractPage::factory($page); } parent::addPage($page); if ($page instanceof AbstractPage) { $page->setRouter($this->router); $page->setRequest($this->request); } return $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(), '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(), 'active' => $this->isActive(), 'visible' => $this->isVisible(), 'type' => get_class($this), 'pages' => parent::toArray())); }
/** * Sets parent container * * @param \Zend\Navigation\Container $parent [optional] new parent to set. * Default is null which will set * no parent. * @return \Zend\Navigation\AbstractPage fluent interface, returns self */ public function setParent(Container $parent = null) { if ($parent === $this) { throw new Exception('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; }
public function addPage($page) { parent::addPage($page); $this->_pages = array(); }