當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。