Esempio n. 1
0
 public function testOrder()
 {
     $page = new Page();
     $page1 = new Page(array('href' => '/test/', 'order' => 99));
     $page2 = new Page(array('href' => '/test_parent/', 'order' => 1));
     $page->addPages(array($page1, $page2));
     foreach ($page as $p) {
         $this->assertEquals(1, $p->getOrder());
         break;
     }
 }
Esempio n. 2
0
 /**
  * Checks if the container has the given page
  *
  * @param \App\Navigation\Page|\App\Navigation\Page\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(Page $page, $recursive = false)
 {
     $hash = $page->getHashCode();
     if (isset($this[$hash])) {
         return true;
     } elseif ($recursive) {
         /** @var $this Page[] */
         foreach ($this as $childPage) {
             if ($childPage->hasPage($page, true)) {
                 return true;
             }
         }
     }
     return false;
 }