當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FactoryInterface::createFromNode方法代碼示例

本文整理匯總了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;
 }
開發者ID:zapoyok,項目名稱:menu-bundle,代碼行數:20,代碼來源:MenuProvider.php

示例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;
 }
開發者ID:netmeansnet,項目名稱:MenuBundle,代碼行數:10,代碼來源:PHPCRMenuProvider.php


注:本文中的Knp\Menu\FactoryInterface::createFromNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。