Exemple #1
0
 /**
  * Retrieves a menu by its name.
  *
  * @param string $name
  * @param array  $options
  *
  * @throws \InvalidArgumentException if the menu does not exists
  * @return \Knp\Menu\ItemInterface
  *
  */
 public function get($name, array $options = [])
 {
     $menu = $this->menuManager->findOneBy(['name' => $name]);
     $menuItem = $this->factory->createFromNode($menu);
     if (empty($menuItem)) {
         throw new \InvalidArgumentException("Menu at '{$name}' is misconfigured (f.e. the route might be incorrect) and could therefore not be instanciated");
     }
     //$menuItem->setCurrentUri($this->request->getRequestUri());
     return $menuItem;
 }
 public function get($name, array $options = array())
 {
     $menu = $this->dm->find($this->className, $this->menuRoot . '/' . $name);
     if ($menu === null) {
         throw new \InvalidArgumentException(sprintf('The menu "%s" is not defined.', $name));
     }
     $menuItem = $this->factory->createFromNode($menu);
     $menuItem->setCurrentUri($this->container->get('request')->getRequestUri());
     return $menuItem;
 }