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


PHP ItemInterface::isDisplayed方法代码示例

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


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

    /**
     * Called by the parent menu item to render this menu.
     *
     * This renders the li tag to fit into the parent ul as well as its
     * own nested ul tag if this menu item has children
     *
     * @param \Knp\Menu\ItemInterface $item
     * @param array $options The options to render the item
     * @return string
     */
    public function renderItem(ItemInterface $item, array $options = array())
    {
        $options = array_merge($this->getDefaultOptions(), $options);

        // if we don't have access or this item is marked to not be shown
        if (!$item->isDisplayed()) {
            return '';
        }

        // explode the class string into an array of classes
        $class = ($item->getAttribute('class')) ? explode(' ', $item->getAttribute('class')) : array();

        if ($item->isCurrent()) {
            $class[] = $options['currentClass'];
        } elseif ($item->isCurrentAncestor()) {
            $class[] = $options['ancestorClass'];
        }

        if ($item->actsLikeFirst()) {
            $class[] = $options['firstClass'];
        }
        if ($item->actsLikeLast()) {
            $class[] = $options['lastClass'];
        }

        // 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());

        // 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 if there are visible children
        if ($item->hasChildren() && 0 !== $options['depth'] && $item->getDisplayChildren()) {

            $childrenClass = ($item->getChildrenAttribute('class')) ? explode(' ', $item->getChildrenAttribute('class')) : array();
            $childrenClass[] = 'menu_level_'.$item->getLevel();

            $childrenAttributes = $item->getChildrenAttributes();
            $childrenAttributes['class'] = implode(' ', $childrenClass);

            $html .= $this->format('<ul'.$this->renderHtmlAttributes($childrenAttributes).'>', 'ul', $item->getLevel());
            $html .= $this->renderChildren($item, $options);
            $html .= $this->format('</ul>', 'ul', $item->getLevel());
        }

        // closing li tag
        $html .= $this->format('</li>', 'li', $item->getLevel());

        return $html;
    }
开发者ID:naderman,项目名称:KnpMenu,代码行数:67,代码来源:ListRenderer.php

示例3: renderItem

 /**
  * Called by the parent menu item to render this menu.
  *
  * This renders the li tag to fit into the parent ul as well as its
  * own nested ul tag if this menu item has children
  *
  * @param ItemInterface $item
  * @param array         $options The options to render the item
  *
  * @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 ($this->matcher->isCurrent($item)) {
         $class[] = $options['currentClass'];
     } elseif ($this->matcher->isAncestor($item, $options['matchingDepth'])) {
         $class[] = $options['ancestorClass'];
     }
     if ($item->actsLikeFirst()) {
         $class[] = $options['firstClass'];
     }
     if ($item->actsLikeLast()) {
         $class[] = $options['lastClass'];
     }
     if ($item->hasChildren() && $options['depth'] !== 0) {
         if (null !== $options['branch_class'] && $item->getDisplayChildren()) {
             $class[] = $options['branch_class'];
         }
     } elseif (null !== $options['leaf_class']) {
         $class[] = $options['leaf_class'];
     }
     // retrieve the attributes and put the final class string back on it
     $attributes = $item->getAttributes();
     if (!empty($class)) {
         $attributes['class'] = implode(' ', $class);
     }
     $html = '';
     $isRightMenu = $item->getExtra('type', 'left-menu') === 'right-menu';
     // Don't render the container if the menu has children but is a right aligned menu
     if ($item->hasChildren() && !$isRightMenu) {
         // opening li tag
         $html = $this->format('<div' . $this->renderHtmlAttributes($attributes) . '>', 'li', $item->getLevel(), $options);
     }
     // render the text/link inside the li tag
     if (!$isRightMenu) {
         $html .= $this->renderLink($item, $options);
     }
     if ($item->hasChildren()) {
         // renders the embedded ul
         $childrenClass = (array) $item->getChildrenAttribute('class');
         $childrenClass[] = 'menu_level_' . $item->getLevel();
         $childrenAttributes = $item->getChildrenAttributes();
         $childrenAttributes['class'] = implode(' ', $childrenClass);
         $html .= $this->renderList($item, $childrenAttributes, $options);
         // closing li tag
         $html .= $this->format('</div>', 'li', $item->getLevel(), $options);
     }
     return $html;
 }
开发者ID:Briareos,项目名称:Undine,代码行数:65,代码来源:SemanticMenuRenderer.php

示例4: renderItem

 protected function renderItem(ItemInterface $item, array $options)
 {
     if (!\App::isGranted($item->getPermissions())) {
         return '';
     }
     // 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 ($this->matcher->isCurrent($item)) {
         $class[] = $options['currentClass'];
     } elseif ($this->matcher->isAncestor($item, $options['matchingDepth'])) {
         $class[] = $options['ancestorClass'];
     }
     if ($item->actsLikeFirst()) {
         $class[] = $options['firstClass'];
     }
     if ($item->actsLikeLast()) {
         $class[] = $options['lastClass'];
     }
     if ($item->hasChildren() && $options['depth'] !== 0) {
         if (null !== $options['branch_class'] && $item->getDisplayChildren()) {
             $class[] = $options['branch_class'];
         }
     } elseif (null !== $options['leaf_class']) {
         $class[] = $options['leaf_class'];
     }
     // 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[] = 'menu_level_'.$item->getLevel();
     $childrenAttributes = $item->getChildrenAttributes();
     // has been set implocitly here, can use ->setChildrenAttributes(array('class'=> 'treeview-menu')) while menu creating
     $childrenAttributes['class'] = 'treeview-menu';
     $childrenAttributes['class'] .= implode(' ', $childrenClass);
     $html .= $this->renderList($item, $childrenAttributes, $options);
     // closing li tag
     $html .= $this->format('</li>', 'li', $item->getLevel(), $options);
     return $html;
 }
开发者ID:santhapa,项目名称:ci-mag-cms,代码行数:51,代码来源:MenuRenderer.php

示例5: hasChildrenHelper

 /**
  * Specifies, whether the children of an item are displayed when rendering the menu
  *
  * @param ItemInterface $item
  *
  * @return bool
  */
 public function hasChildrenHelper(ItemInterface $item)
 {
     if (!$item->isDisplayed()) {
         return false;
     }
     foreach ($item->getChildren() as $child) {
         /** @var ItemInterface $child */
         if (!$child->getExtra("pageTree:hidden", false)) {
             // if we find a child which is not hidden, we need to render the menu
             return true;
         }
     }
     return false;
 }
开发者ID:cH40z-Lord,项目名称:BecklynPageTreeBundle,代码行数:21,代码来源:PageTreeTwigExtension.php

示例6: getItem

 /**
  * @param \Knp\Menu\ItemInterface $item
  * @param array $options
  * @return \Nette\Utils\Html|null
  */
 protected function getItem(ItemInterface $item, array $options)
 {
     if (!$item->isDisplayed()) {
         return null;
     }
     // create an array than can be imploded as a class list
     $class = (array) $item->getAttribute('class');
     if ($this->matcher->isCurrent($item)) {
         $class[] = $options['currentClass'];
     } elseif ($this->matcher->isAncestor($item, $options['ancestorCurrencyDepth'])) {
         $class[] = $options['ancestorClass'];
     }
     if ($item->actsLikeFirst()) {
         $class[] = $options['firstClass'];
     }
     if ($item->actsLikeLast()) {
         $class[] = $options['lastClass'];
     }
     // retrieve the attributes and put the final class string back on it
     $attributes = $item->getAttributes();
     if (!empty($class)) {
         $attributes['class'] = $class;
     }
     $li = Html::el('li', $attributes);
     if (($link = $this->getLink($item, $options)) !== null) {
         $li->add($link);
     }
     // renders the embedded ul
     $childrenClass = (array) $item->getChildrenAttribute('class');
     $childrenClass[] = 'menu_level_' . $item->getLevel();
     $childrenAttributes = $item->getChildrenAttributes();
     $childrenAttributes['class'] = $childrenClass;
     if (($children = $this->getList($item, $childrenAttributes, $options)) !== null) {
         $li->add($children);
     }
     return $li;
 }
开发者ID:TomasVotruba,项目名称:SmfMenu,代码行数:42,代码来源:ListRenderer.php

示例7: isItemAllowed

 /**
  * @param ItemInterface $item
  *
  * @return bool
  */
 protected function isItemAllowed(ItemInterface $item)
 {
     return $item->getExtra('isAllowed') && !in_array($item->getUri(), $this->uris) && $item->getUri() !== '#' && $item->isDisplayed();
 }
开发者ID:xamin123,项目名称:platform,代码行数:9,代码来源:ShortcutsController.php

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