/** * Checks if the container has the given page * * @param \Zend\Navigation\AbstractPage $page page to look for * @param bool $recursive [optional] whether to search * recursively. Default is false. * @return bool whether page is in container */ public function hasPage(AbstractPage $page, $recursive = false) { if (array_key_exists($page->hashCode(), $this->_index)) { return true; } elseif ($recursive) { foreach ($this->_pages as $childPage) { if ($childPage->hasPage($page, true)) { return true; } } } return false; }
/** * Removes the given page from the container * * @param \Zend\Navigation\AbstractPage|int $page page to remove, either a page * instance or a specific page order * @return bool whether the removal was * successful */ public function removePage($page) { if ($page instanceof AbstractPage) { $hash = $page->hashCode(); } elseif (is_int($page)) { $this->_sort(); if (!($hash = array_search($page, $this->_index))) { return false; } } else { return false; } if (isset($this->_pages[$hash])) { unset($this->_pages[$hash]); unset($this->_index[$hash]); $this->_dirtyIndex = true; return true; } return false; }