本文整理汇总了PHP中Knp\Menu\FactoryInterface::createFromNode方法的典型用法代码示例。如果您正苦于以下问题:PHP FactoryInterface::createFromNode方法的具体用法?PHP FactoryInterface::createFromNode怎么用?PHP FactoryInterface::createFromNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Knp\Menu\FactoryInterface
的用法示例。
在下文中一共展示了FactoryInterface::createFromNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* 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;
}
示例2: get
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;
}