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


PHP ItemInterface::getExtra方法代碼示例

本文整理匯總了PHP中Knp\Menu\ItemInterface::getExtra方法的典型用法代碼示例。如果您正苦於以下問題:PHP ItemInterface::getExtra方法的具體用法?PHP ItemInterface::getExtra怎麽用?PHP ItemInterface::getExtra使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Knp\Menu\ItemInterface的用法示例。


在下文中一共展示了ItemInterface::getExtra方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: menuSort

 /**
  * Sort the menu based on weight
  *
  * @param ItemInterface $menuItemA
  * @param ItemInterface $menuItemB
  *
  * @return int
  */
 public static function menuSort(ItemInterface $menuItemA, ItemInterface $menuItemB)
 {
     if ($menuItemA->getExtra('weight') == $menuItemB->getExtra('weight')) {
         return 0;
     }
     return $menuItemA->getExtra('weight') < $menuItemB->getExtra('weight') ? -1 : 1;
 }
開發者ID:fedegiust,項目名稱:Jumph,代碼行數:15,代碼來源:Builder.php

示例2: matchItem

 public function matchItem(ItemInterface $item)
 {
     if (null === $this->request) {
         return null;
     }
     $route = $this->request->attributes->get('_route');
     if (null === $route) {
         return null;
     }
     $routes = (array) $item->getExtra('routes', array());
     $parameters = (array) $item->getExtra('routesParameters', array());
     foreach ($routes as $testedRoute) {
         if (is_string($testedRoute)) {
             $testedRoute = array('route' => $testedRoute);
             // BC layer for the configuration of route params
             if (isset($parameters[$testedRoute['route']])) {
                 $testedRoute['parameters'] = $parameters[$testedRoute['route']];
                 trigger_error('Using the routeParameters extra is deprecated. The parameters should be passed along the route.', E_USER_DEPRECATED);
             }
         }
         if (!is_array($testedRoute)) {
             throw new \InvalidArgumentException('Routes extra items must be strings or arrays.');
         }
         if ($this->isMatchingRoute($testedRoute)) {
             return true;
         }
     }
     return null;
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:29,代碼來源:RouteVoter.php

示例3: matchItem

 /**
  * Checks whether an item is current.
  *
  * If the voter is not able to determine a result,
  * it should return null to let other voters do the job.
  *
  * @param ItemInterface $item
  *
  * @return boolean|null
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getExtra('link', false) && $this->parentControl) {
         $presenter = $this->parentControl->getPresenter(true);
         $item->setCurrent(call_user_func_array(array($presenter, 'isLinkCurrent'), $item->getExtra('link')));
         return $item->isCurrent();
     }
     return null;
 }
開發者ID:TomasVotruba,項目名稱:SmfMenu,代碼行數:19,代碼來源:PresenterVoter.php

示例4: renderLabel

 /**
  * unless 'raw' extra isn't set to true, we try to translate the label.
  *
  * @param ItemInterface $item
  * @param array         $options
  *
  * @return string
  */
 protected function renderLabel(ItemInterface $item, array $options)
 {
     if ($options['allow_safe_labels'] && $item->getExtra('safe_label', false)) {
         return $item->getLabel();
     }
     if ($item->getExtra('raw', false) !== false) {
         return $this->escape($item->getLabel());
     }
     return $this->escape(trans($item->getLabel()));
 }
開發者ID:vainproject,項目名稱:vain,代碼行數:18,代碼來源:VainPresenter.php

示例5: addNavLinkRoute

 protected function addNavLinkRoute(ItemInterface $menu, $label, $route, $routeParameters = array())
 {
     $item = $menu->addChild($label, array('route' => $route, 'routeParameters' => $routeParameters));
     $item->setExtra('translation_domain', $menu->getExtra('translation_domain'));
     $menu->setExtra('request_uri', $menu->getExtra('request_uri'));
     if ($item->getUri() == $menu->getExtra('request_uri')) {
         $item->setAttribute('class', 'active');
     }
     return $item;
 }
開發者ID:ronzalo,項目名稱:dyl_s2,代碼行數:10,代碼來源:Menu.php

示例6: matchItem

 /**
  * Checks whether an item is current.
  *
  * If the voter is not able to determine a result,
  * it should return null to let other voters do the job.
  *
  * @param ItemInterface $item
  * @return boolean|null
  */
 public function matchItem(ItemInterface $item)
 {
     /* @var $request \Symfony\Component\HttpFoundation\Request */
     $request = $this->container->get('request');
     if ($item->getUri() === $request->getRequestUri()) {
         return true;
     }
     if ($item->getExtra('routes') !== null && in_array($request->attributes->get('_route'), $item->getExtra('routes'))) {
         return true;
     }
     return null;
 }
開發者ID:elom5000,項目名稱:BardisCMS,代碼行數:21,代碼來源:RequestVoter.php

示例7: addHiddenItems

 /**
  * @param ItemInterface $parent
  * @param array         $routes
  * @param string|null   $basePath
  */
 public static function addHiddenItems($parent, $routes, $basePath = null)
 {
     $parent->setDisplayChildren(false);
     if (null === $basePath && null !== $parent->getExtra('routes') && isset($parent->getExtra('routes')[0]['route'])) {
         $basePathArray = explode("_", $parent->getExtra('routes')[0]['route']);
         $basePathArray[count($basePathArray) - 1] = '%s';
         $basePath = implode("_", $basePathArray);
     }
     foreach ($routes as $routeIndex => $routeParameters) {
         $route = sprintf($basePath, $routeIndex);
         $parent->addChild($route, ['route' => $route, 'routeParameters' => $routeParameters]);
     }
 }
開發者ID:pmdevelopment,項目名稱:tool-bundle,代碼行數:18,代碼來源:MenuUtility.php

示例8: matchItem

 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     $admin = $item->getExtra('admin');
     $match = null;
     if ($admin instanceof AdminInterface && $admin->hasRoute('list') && $admin->isGranted('LIST') && $this->request && $this->request->get('_sonata_admin') == $admin->getCode()) {
         $match = true;
     }
     $route = $item->getExtra('route');
     if ($route && $this->request && $route == $this->request->get('_route')) {
         $match = true;
     }
     return $match;
 }
開發者ID:drmjo,項目名稱:SonataAdminBundle,代碼行數:16,代碼來源:AdminVoter.php

示例9: matchItem

 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if (($page = $this->getPage()) && $page->getId() !== null) {
         return $item->getExtra('_page_id', null) === $page->getId();
     }
     return;
 }
開發者ID:symedit,項目名稱:symedit,代碼行數:10,代碼來源:PageVoter.php

示例10: matchItem

 /**
  * @param ItemInterface $item
  *
  * @return bool|null
  */
 public function matchItem(ItemInterface $item)
 {
     if (null === $this->getRequest()) {
         return null;
     }
     $route = $this->getRequest()->attributes->get('_route');
     $routeParameters = $this->getRequest()->attributes->get('_route_params');
     if (null === $route) {
         return null;
     }
     $routes = (array) $item->getExtra('routes', array());
     foreach ($routes as $testedRoute) {
         if ($route == $testedRoute['route']) {
             if (is_array($routeParameters) && 0 < count($routeParameters)) {
                 if (isset($testedRoute['parameters']) && is_array($testedRoute['parameters'])) {
                     $matching = true;
                     foreach ($routeParameters as $index => $value) {
                         if ('_' != substr($index, 0, 1)) {
                             if (!isset($testedRoute['parameters'][$index]) || ($testedRoute['parameters'][$index] != $value && 0 < $testedRoute['parameters'][$index] || !is_numeric($value))) {
                                 $matching = false;
                             }
                         }
                     }
                     if ($matching) {
                         return true;
                     }
                 }
             } else {
                 return true;
             }
         }
     }
     return null;
 }
開發者ID:pmdevelopment,項目名稱:tool-bundle,代碼行數:39,代碼來源:RouteVoter.php

示例11: modifyItem

 protected function modifyItem(ItemInterface $item, array $options)
 {
     if (!$item->getExtra('remove_leaf', false)) {
         return;
     }
     if (!$item->hasChildren()) {
         $this->removeItem($item);
     }
 }
開發者ID:symedit,項目名稱:symedit,代碼行數:9,代碼來源:RemoveLeavesExtension.php

示例12: decorate

 public function decorate(KnpMenuItem $knpMenuItem, AdminMenuItem $adminMenuItem)
 {
     if ($adminMenuItem instanceof RoutableItem && $adminMenuItem->getRoute()) {
         $knpMenuItem->setUri($this->router->generate($adminMenuItem->getRoute(), $adminMenuItem->getRouteParameters()));
         $routes = $knpMenuItem->getExtra('routes', array());
         $routes[] = array('route' => $adminMenuItem->getRoute(), 'parameters' => $adminMenuItem->getRouteParameters());
         $knpMenuItem->setExtra('routes', $routes);
     }
 }
開發者ID:kbedn,項目名稱:admin-bundle,代碼行數:9,代碼來源:ItemRouteDecorator.php

示例13: matchItem

 /**
  * {@inheritDoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($prefix = $item->getExtra('prefix_match', $this->defaultActive)) {
         if (strpos($this->getRequestUri(), $item->getUri()) === 0) {
             return true;
         }
     }
     return null;
 }
開發者ID:wemakecustom,項目名稱:menu-part-bundle,代碼行數:12,代碼來源:PrefixVoter.php

示例14: matchItem

 /**
  * {@inheritDoc}
  */
 public function matchItem(ItemInterface $item = null)
 {
     if (!$this->request) {
         return null;
     }
     $content = $item->getExtra('content');
     if (null !== $content && $this->request->attributes->has($this->requestKey) && $this->request->attributes->get($this->requestKey) instanceof $this->childClass && $this->request->attributes->get($this->requestKey)->getParentDocument() === $content) {
         return true;
     }
     return null;
 }
開發者ID:viral810,項目名稱:ngSimpleCMS,代碼行數:14,代碼來源:RequestParentContentIdentityVoter.php

示例15: decorate

 public function decorate(KnpMenuItem $knpMenuItem, AdminMenuItem $adminMenuItem)
 {
     if ($adminMenuItem instanceof ElementItem && $adminMenuItem->hasOption('elements')) {
         $routes = $knpMenuItem->getExtra('routes', array());
         /** @var Element $element */
         foreach ($adminMenuItem->getOption('elements') as $element) {
             $routes[] = array('route' => $element->getRoute(), 'parameters' => $element->getRouteParameters());
         }
         $knpMenuItem->setExtra('routes', $routes);
     }
 }
開發者ID:kbedn,項目名稱:admin-bundle,代碼行數:11,代碼來源:ItemElementsDecorator.php


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