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; }
/** * 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(); }