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


PHP ItemInterface::getLinkAttributes方法代码示例

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


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

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

示例2: getLinkElement

 /**
  * @param \Knp\Menu\ItemInterface $item
  * @param array $options
  * @return Html
  */
 protected function getLinkElement(ItemInterface $item, array $options)
 {
     return Html::el('a', $item->getLinkAttributes())->setHref($this->getUri($item, $options))->setHtml($this->getText($item, $options));
 }
开发者ID:TomasVotruba,项目名称:SmfMenu,代码行数:9,代码来源:ListRenderer.php

示例3: renderLinkElement

 protected function renderLinkElement(ItemInterface $item, array $options)
 {
     return sprintf('<a href="%s"%s>%s</span></a>', $this->escape($item->getUri()), $this->renderHtmlAttributes($item->getLinkAttributes()), $this->renderLabel($item, $options));
 }
开发者ID:bamper,项目名称:symfony-ecommerce,代码行数:4,代码来源:CustomRenderer.php

示例4: renderLinkElement

 protected function renderLinkElement(ItemInterface $item, array $options)
 {
     $class = (array) $item->getLinkAttribute('class');
     $class[] = 'section';
     $attributes = $item->getLinkAttributes();
     $attributes['class'] = implode(' ', $class);
     return sprintf('<a href="%s"%s>%s</a>', $this->escape($item->getUri()), $this->renderHtmlAttributes($attributes), $this->renderLabel($item, $options));
 }
开发者ID:Briareos,项目名称:Undine,代码行数:8,代码来源:SemanticBreadcrumbsRenderer.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

示例6: renderLinkElement

 protected function renderLinkElement(ItemInterface $item, array $options)
 {
     $attributes = $item->getLinkAttributes();
     $attributes['class'] = isset($attributes['class']) ? $attributes['class'] . ' item' : 'item';
     if ($this->matcher->isCurrent($item)) {
         $attributes['class'] = $attributes['class'] . ' active';
     }
     $position = $item->getExtra('position', 'left');
     $link = sprintf('<a href="%s"%s>%s</a>', $this->escape($item->getUri()), $this->renderHtmlAttributes($attributes), $this->renderLabel($item, $options));
     return $link;
 }
开发者ID:Briareos,项目名称:Undine,代码行数:11,代码来源:SemanticMenuRenderer.php


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