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


PHP ItemInterface::getDisplayChildren方法代码示例

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


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

示例1: sort

 /**
  * Reorder menu based on position attribute
  *
  * @param ItemInterface $menu
  */
 protected function sort(ItemInterface $menu)
 {
     if ($menu->hasChildren() && $menu->getDisplayChildren()) {
         $orderedChildren = [];
         $unorderedChildren = [];
         $hasOrdering = false;
         $children = $menu->getChildren();
         foreach ($children as &$child) {
             if ($child->hasChildren() && $child->getDisplayChildren()) {
                 $this->sort($child);
             }
             $position = $child->getExtra('position');
             if ($position !== null) {
                 $orderedChildren[$child->getName()] = (int) $position;
                 $hasOrdering = true;
             } else {
                 $unorderedChildren[] = $child->getName();
             }
         }
         if ($hasOrdering) {
             asort($orderedChildren);
             $menu->reorderChildren(array_merge(array_keys($orderedChildren), $unorderedChildren));
         }
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:30,代码来源:BuilderChainProvider.php

示例2: getList

 /**
  * @param \Knp\Menu\ItemInterface $item
  * @param $attributes
  * @param $options
  * @return \Nette\Utils\Html|null
  */
 protected function getList(ItemInterface $item, $attributes, $options)
 {
     if (!$item->hasChildren() || 0 === $options['depth'] || !$item->getDisplayChildren()) {
         return null;
     }
     $list = Html::el('ul', $attributes);
     foreach ($this->getChildren($item, $options) as $child) {
         $list->add($child);
     }
     return $list;
 }
开发者ID:TomasVotruba,项目名称:SmfMenu,代码行数:17,代码来源:ListRenderer.php

示例3: 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('<ul>', 'ul', $item->getLevel(), $options);
     $html .= $this->renderChildren($item, $options);
     $html .= $this->format('</ul>', 'ul', $item->getLevel(), $options);
     return $html;
 }
开发者ID:bamper,项目名称:symfony-ecommerce,代码行数:16,代码来源:CustomRenderer.php

示例4: render

    /**
     * @see RendererInterface::render
     */
    public function render(ItemInterface $item, array $options = array())
    {
        $options = array_merge($this->getDefaultOptions(), $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('<ul'.$this->renderHtmlAttributes($item->getAttributes()).'>', 'ul', $item->getLevel());
        $html .= $this->renderChildren($item, $options);
        $html .= $this->format('</ul>', 'ul', $item->getLevel());

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

示例5: buildClasses

 /**
  * Concats the appropriate classes for menu links
  *
  * @param ItemInterface    $item
  * @param MatcherInterface $matcher
  * @param array            $options
  */
 public function buildClasses(ItemInterface &$item, MatcherInterface &$matcher, $options)
 {
     $showChildren = $item->hasChildren() && $item->getDisplayChildren();
     $isAncestor = $matcher->isAncestor($item, $options["matchingDepth"]);
     $isCurrent = $matcher->isCurrent($item);
     $class = $item->getAttribute("class");
     $classes = $class ? " {$class}" : "";
     $classes .= $isCurrent ? " {$options["currentClass"]}" : "";
     $classes .= $isAncestor ? " {$options["ancestorClass"]}" : "";
     $classes .= $isAncestor && $this->invisibleChildSelected($item, $matcher) ? " {$options["currentClass"]}" : "";
     $classes .= $item->actsLikeFirst() ? " {$options["firstClass"]}" : "";
     $classes .= $item->actsLikeLast() ? " {$options["lastClass"]}" : "";
     $item->setAttribute("class", trim($classes));
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:21,代码来源:MenuHelper.php

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