Ejemplo n.º 1
0
 /**
  * Checks if the container has the given page
  *
  * @param  \Zend\Navigation\Page\Page $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(Page\Page $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;
 }
Ejemplo n.º 2
0
 /**
  * Removes the given page from the container
  *
  * @param  \Zend\Navigation\Page\Page|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 Page\Page) {
         $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;
 }