/** * Generate admin menu navigation object * * @return \Knp\Menu\ItemInterface */ public function adminMenu() { static $adminMenu; if (empty($adminMenu)) { $loader = new ArrayLoader($this->factory); //dispatch the MENU_BUILD event to retrieve bundle menu items $event = new MenuEvent($this->menuHelper, 'admin'); $this->dispatcher->dispatch(CoreEvents::BUILD_MENU, $event); $menuItems = $event->getMenuItems(); $adminMenu = $loader->load($menuItems); } return $adminMenu; }
/** * @expectedException \InvalidArgumentException */ public function testLoadInvalidData() { $loader = new ArrayLoader(new MenuFactory()); $loader->load(new \stdClass()); }
/** * Creates a new menu item (and tree if $data['children'] is set). * * The source is an array of data that should match the output from MenuManipulator->toArray(). * * @deprecated Use \Knp\Menu\Loader\ArrayLoader * * @param array $data The array of data to use as a source for the menu tree * * @return ItemInterface */ public function createFromArray(array $data) { trigger_error(__METHOD__ . ' is deprecated. Use Knp\\Menu\\Loader\\ArrayLoader instead', E_USER_DEPRECATED); $loader = new ArrayLoader($this); return $loader->load($data); }
/** * @param $name * * @return mixed */ private function buildMenu($name) { static $menus = array(); if (!isset($menus[$name])) { $loader = new ArrayLoader($this->factory); //dispatch the MENU_BUILD event to retrieve bundle menu items $event = new MenuEvent($this->menuHelper, $name); $this->dispatcher->dispatch(CoreEvents::BUILD_MENU, $event); $menuItems = $event->getMenuItems(); $menus[$name] = $loader->load($menuItems); } return $menus[$name]; }