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

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

Add to a leaf to nav tree branch
public addLeaf ( string $branch, array $leaf, integer $pos = null, boolean $prepend = false ) : Nav
$branch string
$leaf array
$pos integer
$prepend boolean
Результат Nav
    public function addLeaf($branch, array $leaf, $pos = null, $prepend = false)
    {
        $this->tree = $this->traverseTree($this->tree, $branch, $leaf, $pos, $prepend);
        $this->parentLevel = 1;
        $this->childLevel = 1;
        return $this;
    }

Usage Example

Пример #1
0
    public function testAddLeaf()
    {
        $_SERVER['REQUEST_URI'] = '/first';
        $tree = array(array('name' => 'First Nav Item', 'href' => '/first'), array('name' => 'Second Nav Item', 'href' => '/second'));
        $n = new Nav($tree);
        $n->addLeaf('Second Nav Item', array('name' => 'A Brand New Child', 'href' => 'a-brand-new-child'));
        $navString = <<<NAV
        <a href="/second">Second Nav Item</a>
        <ul>
            <li>
                <a href="/second/a-brand-new-child">A Brand New Child</a>
            </li>
        </ul>
NAV;
        $this->assertContains($navString, (string) $n);
    }
All Usage Examples Of Pop\Nav\Nav::addLeaf