Menu\Items\ItemList::add PHP Method

add() public method

Add a item to the default menu Menu::add('home', 'Homepage'); Add a item with a subitem to the default menu Menu::add('home', 'Homepage', Menu::items()->add('home/sub', 'Subitem')); Add a item with attributes for the item's HTML element Menu::add('home', 'Homepage', null, array('class' => 'fancy'));
public add ( string $url, string $value, ItemList $children = null, array $linkAttributes = [], array $itemAttributes = [], string $itemElement = null, string $beforeContent = null, string $afterContent = null ) : ItemList
$url string Url of the link
$value string (H)T(ML) inside of the link
$children ItemList Children
$linkAttributes array Attributes for the link
$itemAttributes array Attributes for the item
$itemElement string The element for the item
$beforeContent string String to add before the link
$afterContent string String to add after the link
return ItemList
    public function add($url, $value, $children = null, $linkAttributes = array(), $itemAttributes = array(), $itemElement = null, $beforeContent = null, $afterContent = null)
    {
        $content = new Link($url, $value, $linkAttributes);
        $item = $this->addContent($content, $children, $itemAttributes, $itemElement, $beforeContent, $afterContent);
        return $this;
    }

Usage Example

Ejemplo n.º 1
0
 public function testMenuCanSetGlobalOptions()
 {
     Menu::setOption('item.element', 'dl');
     $list = new ItemList();
     $list->add('#', 'foo');
     $this->assertHTML($this->matchListWithItem('ul', 'dl'), $list->render());
     $this->assertHTML($this->matchLink(), $list->render());
 }