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


PHP ItemInterface::isCurrent方法代碼示例

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


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

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

示例2: isCurrent

 public function isCurrent(ItemInterface $item)
 {
     $current = $item->isCurrent();
     if (null !== $current) {
         return $current;
     }
     if ($this->cache->contains($item)) {
         return $this->cache[$item];
     }
     foreach ($this->voters as $voter) {
         $current = $voter->matchItem($item);
         if (null !== $current) {
             break;
         }
     }
     $current = (bool) $current;
     $this->cache[$item] = $current;
     return $current;
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:19,代碼來源:Matcher.php

示例3: renderLink

    /**
     * Renders the link in a a tag with link attributes or
     * the label in a span tag with label attributes
     *
     * Tests if item has a an uri and if not tests if it's
     * the current item and if the text has to be rendered
     * as a link or not.
     *
     * @param \Knp\Menu\ItemInterface $item The item to render the link or label for
     * @param array $options The options to render the item
     * @return string
     */
    public function renderLink(ItemInterface $item, array $options = array())
    {
        $options = array_merge($this->getDefaultOptions(), $options);

        if ($item->getUri() && (!$item->isCurrent() || $options['currentAsLink'])) {
            $text = sprintf('<a href="%s"%s>%s</a>', $this->escape($item->getUri()), $this->renderHtmlAttributes($item->getLinkAttributes()), $this->escape($item->getLabel()));
        } else {
            $text = sprintf('<span%s>%s</span>', $this->renderHtmlAttributes($item->getLabelAttributes()), $this->escape($item->getLabel()));
        }

        return $this->format($text, 'link', $item->getLevel());
    }
開發者ID:naderman,項目名稱:KnpMenu,代碼行數:24,代碼來源:ListRenderer.php

示例4: renderLink

 /**
  * Renders the link in a a tag with link attributes or
  * the label in a span tag with label attributes
  *
  * Tests if item has a an uri and if not tests if it's
  * the current item and if the text has to be rendered
  * as a link or not.
  *
  * @param \Knp\Menu\ItemInterface $item The item to render the link or label for
  * @param array $options The options to render the item
  * @return string
  */
 protected function renderLink(ItemInterface $item, array $options = array())
 {
     if ($item->getUri() && (!$item->isCurrent() || $options['currentAsLink'])) {
         $text = $this->renderLinkElement($item, $options);
     } else {
         $text = $this->renderSpanElement($item, $options);
     }
     return $this->format($text, 'link', $item->getLevel(), $options);
 }
開發者ID:bamper,項目名稱:symfony-ecommerce,代碼行數:21,代碼來源:CustomRenderer.php

示例5: toArray

 /**
  * @param ItemInterface $item
  * @param integer|null  $depth the depth until which children should be exported (null means unlimited)
  *
  * @return array
  */
 public function toArray(ItemInterface $item, $depth = null)
 {
     $array = array('name' => $item->getName(), 'label' => $item->getLabel(), 'uri' => $item->getUri(), 'attributes' => $item->getAttributes(), 'labelAttributes' => $item->getLabelAttributes(), 'linkAttributes' => $item->getLinkAttributes(), 'childrenAttributes' => $item->getChildrenAttributes(), 'extras' => $item->getExtras(), 'display' => $item->isDisplayed(), 'displayChildren' => $item->getDisplayChildren(), 'current' => $item->isCurrent());
     // export the children as well, unless explicitly disabled
     if (0 !== $depth) {
         $childDepth = null === $depth ? null : $depth - 1;
         $array['children'] = array();
         foreach ($item->getChildren() as $key => $child) {
             $array['children'][$key] = $this->toArray($child, $childDepth);
         }
     }
     return $array;
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:19,代碼來源:MenuManipulator.php


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