/** * {@inheritdoc} */ public function add(ItemInterface $item, ItemInterface $before = null) { $this->load(); return parent::add($item, $before); }
/** * Create the root item and items collection and assign to the template. * * @param MenuModel $menu * @param string $rootType * @param string $rootName */ protected function createItems(MenuModel $menu, $rootType, $rootName) { $providerFactory = new ProviderFactory(); // create local event dispatcher and provider $eventDispatcher = $this->createLocalEventDispatcher($menu, $providerFactory); // create the event driven menu $eventDrivenItemFactory = new EventDrivenItemFactory($eventDispatcher, XNavigationEvents::CREATE_ITEM, XNavigationEvents::COLLECT_ITEMS); // create the root item $item = $eventDrivenItemFactory->createItem($rootType, $rootName); // create the items collection if ($menu->include_root) { $collection = new ItemCollection(); $collection->add($item); } else { $collection = $item->getChildren(); } $this->Template->item = $item; $this->Template->items = $collection; }