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


PHP ItemInterface::getLabel方法代碼示例

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


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

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

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

示例3: buildItem

 /**
  * Configures the newly created item with the passed options
  *
  * @param ItemInterface $item
  * @param array         $options
  */
 public function buildItem(ItemInterface $item, array $options)
 {
     if (!empty($options['path'])) {
         $item->setUri(site_url($options['path']));
     }
     if (!empty($options['icon_class'])) {
         $item->setLabel('<i class="' . $options['icon_class'] . '"></i> ' . $item->getLabel());
         $item->setExtra('safe_label', true);
     }
     $this->buildExtras($item, $options);
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:17,代碼來源:CoreExtension.php

示例4: renderLabel

 protected function renderLabel(ItemInterface $item, array $options)
 {
     $html = '<i class="' . $item->getIcon() . '"></i> ';
     $html .= '<span>' . $item->getLabel() . '</span>';
     if ($item->hasChildren()) {
         $drop = false;
         foreach ($item->getChildren() as $child) {
             if (\App::isGranted($child->getPermissions())) {
                 $drop = true;
             }
         }
         if ($drop) {
             $html .= '<i class="fa fa-angle-left pull-right"></i>';
         }
     }
     return $html;
 }
開發者ID:santhapa,項目名稱:ci-mag-cms,代碼行數:17,代碼來源:MenuRenderer.php

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

示例6: getText

 /**
  * @param \Knp\Menu\ItemInterface $item
  * @param array $options
  * @return string
  */
 protected function getText(ItemInterface $item, array $options)
 {
     if ($options['allow_safe_labels'] && $item->getExtra('safe_label', false)) {
         return $item->getLabel();
     }
     return $this->escape($item->getLabel());
 }
開發者ID:TomasVotruba,項目名稱:SmfMenu,代碼行數:12,代碼來源:ListRenderer.php

示例7: renderLabel

 /**
  * Renders the menu label.
  *
  * @param Item  $item
  * @param array $options
  *
  * @return string
  */
 protected function renderLabel(Item $item, array $options)
 {
     $icon = '';
     if ($item->getExtra('icon')) {
         $icon = $this->renderIcon($item->getExtra('icon'));
     }
     if ($options['allow_safe_labels'] && $item->getExtra('safe_label', false)) {
         return $icon . $item->getLabel();
     }
     return $icon . $this->escape($item->getLabel());
 }
開發者ID:Codixis,項目名稱:CSBill,代碼行數:19,代碼來源:Renderer.php

示例8: getBreadcrumbsItem

 private function getBreadcrumbsItem(ItemInterface $item)
 {
     return array('label' => $item->getLabel(), 'uri' => $item->getUri(), 'item' => $item);
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:4,代碼來源:MenuManipulator.php


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