当前位置: 首页>>代码示例>>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;未经允许,请勿转载。