当前位置: 首页>>代码示例>>PHP>>正文


PHP ItemInterface::getUri方法代码示例

本文整理汇总了PHP中Knp\Menu\ItemInterface::getUri方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemInterface::getUri方法的具体用法?PHP ItemInterface::getUri怎么用?PHP ItemInterface::getUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Knp\Menu\ItemInterface的用法示例。


在下文中一共展示了ItemInterface::getUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: matchItem

 public function matchItem(ItemInterface $item)
 {
     $route = substr($this->container->get('request')->getRequestUri(), 0, strlen($item->getUri()));
     $method = substr(strrchr($this->container->get('request')->getRequestUri(), '/'), 1);
     if ($route == $item->getUri() && ($method == 'modifier' || $method == 'importer' || $method == 'ajouter')) {
         return true;
     }
     return null;
 }
开发者ID:Bobarisoa,项目名称:noucoz-release,代码行数:9,代码来源:RequestVoter.php

示例2: matchItem

 public function matchItem(ItemInterface $item)
 {
     if (null === $this->uri || null === $item->getUri()) {
         return null;
     }
     if ($item->getUri() === $this->uri) {
         return true;
     }
     return null;
 }
开发者ID:andrewkrug,项目名称:repucaution,代码行数:10,代码来源:UriVoter.php

示例3: matchItem

 public function matchItem(ItemInterface $item)
 {
     if (null === $this->regexp || null === $item->getUri()) {
         return null;
     }
     if (preg_match($this->regexp, $item->getUri())) {
         return true;
     }
     return null;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:10,代码来源:RegexVoter.php

示例4: matchItem

 public function matchItem(ItemInterface $item)
 {
     if ($item->getUri() === $this->container->get('request')->getRequestUri()) {
         return true;
     } else {
         if ($item->getUri() !== '/' && substr($this->container->get('request')->getRequestUri(), 0, strlen($item->getUri())) === $item->getUri()) {
             return true;
         }
     }
     return null;
 }
开发者ID:ner0tic,项目名称:landmarxApp,代码行数:11,代码来源:RequestVoter.php

示例5: matchItem

 public function matchItem(ItemInterface $item)
 {
     if (null === $this->uri || null === $item->getUri()) {
         return null;
     }
     $urlLength = strlen($item->getUri());
     $currentUrlTrimmed = substr($this->uri, 0, $urlLength);
     if ($item->getUri() === $currentUrlTrimmed) {
         return true;
     }
     return null;
 }
开发者ID:andrewkrug,项目名称:repucaution,代码行数:12,代码来源:UrlVoter.php

示例6: matchItem

 public function matchItem(ItemInterface $item)
 {
     if ($item->getUri() === $this->container->get('request')->getRequestUri()) {
         // URL's completely match
         return true;
     } else {
         if ($item->getUri() !== $this->container->get('request')->getBaseUrl() . '/' && substr($this->container->get('request')->getRequestUri(), 0, strlen($item->getUri())) === $item->getUri()) {
             // URL isn't just "/" and the first part of the URL match
             return true;
         }
     }
     return null;
 }
开发者ID:ne0shad0w,项目名称:FrontBundle,代码行数:13,代码来源:RequestVoter.php

示例7: matchItem

 public function matchItem(ItemInterface $item)
 {
     $request = $this->requestStack->getCurrentRequest();
     if ($item->getUri() === $request->getRequestUri()) {
         // URL's completely match
         return true;
     } else {
         if ($item->getUri() !== $request->getBaseUrl() . '/' && substr($request->getRequestUri(), 0, strlen($item->getUri())) === $item->getUri()) {
             // URL isn't just "/" and the first part of the URL match
             return true;
         }
     }
     return null;
 }
开发者ID:phpink,项目名称:nami-core-bundle,代码行数:14,代码来源:RequestVoter.php

示例8: matchItem

 /**
  * {@inheritDoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getUri() === $this->getRequestUri()) {
         return true;
     }
     return null;
 }
开发者ID:wemakecustom,项目名称:menu-part-bundle,代码行数:10,代码来源:RequestVoter.php

示例9: render

 public function render(ItemInterface $item, array $options = array())
 {
     $options = array_merge($this->defaultOptions, $options);
     $translator = $options['translator'];
     $itemIterator = new \Knp\Menu\Iterator\RecursiveItemIterator($item);
     $iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
     $items = [];
     foreach ($iterator as $item) {
         $translatedLabel = $translator->trans($item->getLabel());
         $id = $item->getName();
         $itemData = ['id' => strtolower($item->getName()), 'name' => $translatedLabel, 'uri' => $item->getUri()];
         $itemData['has_children'] = $item->hasChildren();
         $parentId = $item->getParent()->getName();
         if ($parentId !== $id) {
             $itemData['parent'] = strtolower($parentId);
             if (!isset($items[$parentId]['children'])) {
                 $items[$parentId]['children'] = [];
             }
             $items[$parentId]['children'][] = $itemData;
         }
         if (isset($items[$id])) {
             $items[$id] = array_merge($itemData, $items[$id]);
         } else {
             $items[$id] = $itemData;
         }
     }
     return $items;
 }
开发者ID:bgamrat,项目名称:crispy-octo-parakeet,代码行数:28,代码来源:JsonRenderer.php

示例10: 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 \Knp\Menu\ItemInterface $item The item
  *
  * @return boolean|null
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getUri() === $this->container->get('request')->getRequestUri()) {
         return true;
     }
     return false;
 }
开发者ID:rmzamora,项目名称:bootstrap-bundle,代码行数:17,代码来源:RequestVoter.php

示例11: 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 \Knp\Menu\ItemInterface $item The item
  *
  * @return boolean|null
  */
 public function matchItem(ItemInterface $item)
 {
     $uri = str_replace(array('/', '.'), array('\\/', '\\.'), $item->getUri());
     if (preg_match('/' . $uri . '/', $this->container->get('request')->getRequestUri())) {
         return true;
     }
     return false;
 }
开发者ID:rmzamora,项目名称:bootstrap-bundle,代码行数:18,代码来源:RequestRegexVoter.php

示例12: 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

示例13: 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

示例14: matchItem

 /**
  * @param ItemInterface $item
  *
  * @return bool
  */
 public function matchItem(ItemInterface $item)
 {
     $requestUri = $this->request->getRequestUri();
     $baseUrl = $this->request->getBaseUrl() . '/';
     $uri = $item->getUri();
     if ($uri === $requestUri) {
         return true;
     } else {
         if ($uri !== $baseUrl && substr($requestUri, 0, strlen($uri)) === $uri) {
             return true;
         }
     }
     return null;
 }
开发者ID:RamosBruno,项目名称:facebookQuizz,代码行数:19,代码来源:RequestVoter.php

示例15: processMenuItem

 private function processMenuItem(ItemInterface $menu)
 {
     $uri = $menu->getUri();
     if (!empty($uri) || $uri !== '#') {
         if (false === $this->hasAccess($uri)) {
             $menu->getParent()->removeChild($menu);
             return;
         }
     }
     if ($menu->hasChildren()) {
         foreach ($menu->getChildren() as $item) {
             $this->processMenuItem($item);
         }
     }
     if ((empty($uri) || $uri === '#') && $menu->getName() !== 'root' && !$menu->hasChildren()) {
         $menu->getParent()->removeChild($menu);
     }
 }
开发者ID:harpcio,项目名称:sf2-demo,代码行数:18,代码来源:AccessFilter.php


注:本文中的Knp\Menu\ItemInterface::getUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。