本文整理匯總了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;
}