Pop\Nav\Nav::rebuild PHP Метод

rebuild() публичный Метод

Re-build the nav object
public rebuild ( ) : Nav
Результат Nav
    public function rebuild()
    {
        $this->parentLevel = 1;
        $this->childLevel = 1;
        $this->nav = $this->traverse($this->tree);
        return $this;
    }

Usage Example

Пример #1
0
 public function testRebuildNav()
 {
     $_SERVER['REQUEST_URI'] = '/first';
     $tree = array(array('name' => 'First Nav Item', 'href' => '/first', 'children' => array(array('name' => 'First Child', 'href' => 'first-child'), array('name' => 'Second Child', 'href' => 'second-child'))), array('name' => 'Second Nav Item', 'href' => '/second', 'attributes' => array('style' => 'display: block;')));
     $config = array('top' => array('node' => 'ul', 'id' => 'main-nav', 'class' => 'main-nav', 'attributes' => array('style' => 'display: block;')), 'parent' => array('node' => 'ul', 'id' => 'nav', 'class' => 'level', 'attributes' => array('style' => 'display: block;')), 'child' => array('node' => 'li', 'id' => 'menu', 'class' => 'item', 'attributes' => array('style' => 'display: block;')));
     $n = new Nav($tree, $config);
     $r = $n->render(true);
     ob_start();
     $n->render();
     echo $n;
     $output = ob_get_clean();
     $this->assertNotContains('New Nav Item', $r);
     $this->assertNotContains('New Nav Item', $output);
     $n->addBranch(array('name' => 'New Nav Item', 'href' => '/new-nav'));
     $n->rebuild();
     $r = $n->render(true);
     ob_start();
     $n->render();
     echo $n;
     $output = ob_get_clean();
     $this->assertContains('New Nav Item', $r);
     $this->assertContains('New Nav Item', $output);
 }