Lavary\Menu\Item::add PHP Method

add() public method

Creates a sub Item
public add ( string $title, string | array $options = '' ) : void
$title string
$options string | array
return void
    public function add($title, $options = '')
    {
        if (!is_array($options)) {
            $url = $options;
            $options = array();
            $options['url'] = $url;
        }
        $options['parent'] = $this->id;
        return $this->builder->add($title, $options);
    }

Usage Example

コード例 #1
0
 /**
  * Build a child menu item as the descendent of a previously created menu item.
  *
  * @param MenuModel $descendant
  * @param MenuItem|MenuBuilder  $menuItem parent menu item
  * @return MenuItem
  */
 protected function renderChildNode(MenuModel $descendant, $menuItem)
 {
     /** @var MenuItem $childNode */
     $childNode = $menuItem->add($descendant->name, $this->getMenuData($descendant));
     return $childNode;
 }