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


PHP ItemInterface::getLevel方法代码示例

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


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

示例1: renderItem

 /**
  * @param ItemInterface $item
  * @param array         $options
  *
  * @return string
  */
 protected function renderItem(ItemInterface $item, array $options)
 {
     // if we don't have access or this item is marked to not be shown
     if (!$item->isDisplayed()) {
         return '';
     }
     // create an array than can be imploded as a class list
     $class = (array) $item->getAttribute('class');
     if ($item->getLevel() === 1) {
         $class[] = 'treeview';
     }
     if ($this->matcher->isCurrent($item) || $this->matcher->isAncestor($item, $options['matchingDepth'])) {
         $class[] = $options['currentClass'];
     }
     // retrieve the attributes and put the final class string back on it
     $attributes = $item->getAttributes();
     if (!empty($class)) {
         $attributes['class'] = implode(' ', $class);
     }
     // opening li tag
     $html = $this->format('<li' . $this->renderHtmlAttributes($attributes) . '>', 'li', $item->getLevel(), $options);
     // render the text/link inside the li tag
     //$html .= $this->format($item->getUri() ? $item->renderLink() : $item->renderLabel(), 'link', $item->getLevel());
     $html .= $this->renderLink($item, $options);
     // renders the embedded ul
     $childrenClass = (array) $item->getChildrenAttribute('class');
     $childrenClass[] = 'treeview-menu';
     $childrenAttributes = $item->getChildrenAttributes();
     $childrenAttributes['class'] = implode(' ', $childrenClass);
     $html .= $this->renderList($item, $childrenAttributes, $options);
     // closing li tag
     $html .= $this->format('</li>', 'li', $item->getLevel(), $options);
     return $html;
 }
开发者ID:vainproject,项目名称:vain,代码行数:40,代码来源:BackendPresenter.php

示例2: renderList

 protected function renderList(ItemInterface $item, array $attributes, array $options)
 {
     /*
      * Return an empty string if any of the following are true:
      *   a) The menu has no children eligible to be displayed
      *   b) The depth is 0
      *   c) This menu item has been explicitly set to hide its children
      */
     if (!$item->hasChildren() || 0 === $options['depth'] || !$item->getDisplayChildren()) {
         return '';
     }
     $html = $this->format('<div' . $this->renderHtmlAttributes($attributes) . '>', 'ul', $item->getLevel(), $options);
     $html .= $this->renderChildren($item, $options);
     $html .= $this->format('</div>', 'ul', $item->getLevel(), $options);
     return $html;
 }
开发者ID:Briareos,项目名称:Undine,代码行数:16,代码来源:SemanticBreadcrumbsRenderer.php

示例3: getLevel

 public function getLevel()
 {
     return $this->parent ? $this->parent->getLevel() + 1 : 0;
 }
开发者ID:andrewkrug,项目名称:repucaution,代码行数:4,代码来源:MenuItem.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
     */
    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

示例5: getRealLevel

 protected function getRealLevel(ItemInterface $item, array $options)
 {
     return $item->getLevel() - $options['rootLevel'];
 }
开发者ID:TomasVotruba,项目名称:SmfMenu,代码行数:4,代码来源:ListRenderer.php

示例6: renderDivider

 /**
  * @param Item  $item
  * @param array $options
  *
  * @return string
  */
 protected function renderDivider(Item $item, array $options = array())
 {
     return $this->format('<li' . $this->renderHtmlAttributes(array('class' => 'divider' . $item->getExtra('divider'))) . '>', 'li', $item->getLevel(), $options);
 }
开发者ID:Codixis,项目名称:CSBill,代码行数:10,代码来源:Renderer.php

示例7: getChildOptions

 /**
  * Gets guessed values for different menu/nav types.
  *
  * @param ItemInterface $item
  * @param array         $options
  *
  * @return array
  */
 protected function getChildOptions(ItemInterface $item, array $options)
 {
     $childOptions = array();
     $hasChildren = $item->hasChildren() && (!isset($options['depth']) || $options['depth'] > $item->getLevel());
     if (in_array($options['automenu'], array('navbar')) && $hasChildren) {
         $childOptions = array('dropdown' => !isset($options['dropdown']) || $options['dropdown'], 'caret' => !isset($options['caret']) || $options['caret']);
     }
     if (in_array($options['automenu'], array('list-group'))) {
         $childOptions = array('list-group-item' => true);
     }
     return array_merge($options, $childOptions);
 }
开发者ID:CharguiTaieb,项目名称:MopaBootstrapBundle,代码行数:20,代码来源:MenuConverter.php


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