/**
  * Create the menu subtree starting from name.
  *
  * If the name is not already absolute, it is interpreted relative to the
  * menu root. You can thus pass a name or any relative path with slashes to
  * only load a submenu rather than a whole menu.
  *
  * @param string $name    Name of the menu to load. This can be an
  *                        absolute PHPCR path or one relative to the menu root
  * @param array  $options
  *
  * @return ItemInterface The menu (sub)tree starting with name
  *
  * @throws \InvalidArgumentException if the menu can not be found
  */
 public function get($name, array $options = array())
 {
     $menu = $this->find($name, $options, true);
     $menuItem = $this->loader->load($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");
     }
     return $menuItem;
 }
Beispiel #2
0
 /**
  * Create a menu item from a NodeInterface
  *
  * @deprecated Use \Knp\Menu\Loader\NodeLoader
  *
  * @param NodeInterface $node
  *
  * @return ItemInterface
  */
 public function createFromNode(NodeInterface $node)
 {
     trigger_error(__METHOD__ . ' is deprecated. Use Knp\\Menu\\Loader\\NodeLoader instead', E_USER_DEPRECATED);
     $loader = new NodeLoader($this);
     return $loader->load($node);
 }