Builds an ordered list.

@param  array  $items        Items
@param  string $marker       Item marker
@param  int    $nestingLevel Nesting level
@param  int    $parentWidth  Parent marker width
@return string
164443
protected function buildList(array $items, string $marker, int $nestingLevel = 0, int $parentWidth = 0): string
	{
		$width  = $this->calculateWidth($items, $marker);
		$number = 0;
		$list   = '';

		foreach($items as $item)
		{
			if(is_array($item))
			{
				$list .= $this->buildList($item, $marker, ($nestingLevel + 1), ($width['marker'] - 1 + $parentWidth));
			}
			else
			{
				$list .= $this->buildListItem($item, $marker, $width['number'], ++$number, $nestingLevel, $parentWidth);
			}
		}

		return $list;
	}
1295292
private function buildMenuTree(array $elements, $parentRoute = '', $fillIncorrect = true)
    {
        $branch = [];

        foreach ( $elements as $element ) {
            $parent = array_get($element, 'parent');

            if( $parent == $parentRoute ) {
                $children = $this->buildMenuTree($elements, $element['route'], $fillIncorrect);

                if( $children ) {
                    $element['children'] = $children;
                }

                $branch[] = $element;
            } else if( ! is_null($parent) && $fillIncorrect ) {
                $value = array_first($elements, function ($value, $key) use ($parent) {
                    return $value['route'] == $parent;
                }, false);

                if( ! $value ) {
                    $this->itemsWithoutParent[] = $element;
                }
            }
        }

        return $branch;
    }
1097802
public function build($class, $id, $path, $label, $permission, $options = [])
    {
        return new ParentItem(
            $this->itemBuilder,
            $id,
            $path,
            $label,
            $this->adminGroups,
            $permission
        );
    }
210690
private function getItems(NavContainer $container, $parentNavId = 0, $parentGroup = [], $index = 1)
    {
        $navs = $container->getNavs()->andWhere(['parent_nav_id' => $parentNavId])->all();

        foreach ($navs as $nav) {
            $array = $nav->toArray();

            if (empty($nav->activeLanguageItem)) {
                continue;
            }
            $array['title'] = $nav->activeLanguageItem->title;

            foreach ($this->getGroups() as $key => $group) {
                $isInheritedFromParent = false;

                if (isset($parentGroup[$key])) {
                    if ($parentGroup[$key]['isGroupPermissionInheritNode'] || $parentGroup[$key]['isInheritedFromParent']) {
                        $isInheritedFromParent = true;
                    }
                }

                $array['groups'][$key] = [
                    'id' => $group->id,
                    'isGroupPermissionInheritNode' => $nav->isGroupPermissionInheritNode($group),
                    'hasGroupPermission' => $nav->hasGroupPermission($group),
                    'isInheritedFromParent' => $isInheritedFromParent,
                    'permissionCheckbox' => $nav->hasGroupPermissionSelected($group),
                    'groupFullPermission' => $this->groupHasFullPermission($group),
                ];
            }

            $array['nav_level'] = $index;

            self::$_permissionItemData[$container->id][] = $array;

            $this->getItems($container, $nav->id, $array['groups'], $index+1);
        }
    }
786970
public function render($key, array $items = [], array $options = [], $level = 1)
    {
        $i = 0;
        $output    = [];
        $options   = Hash::merge($this->_default, $options);
        $sorted    = Hash::sort($items, '{s}.weight', 'ASC');
        $itemCount = count($sorted);

        foreach ($sorted as $item) {
            $i++;
            $item = $this->_setFirstLast($i, $itemCount, $item);

            $children = false;
            if (count($item['children']) > 0) {
                $children = $this->render($key, $item['children'], $options, $level + 1);
            }

            $itemParams = [
                'options'  => $options,
                'item'     => $item,
                'count'    => $i,
                'children' => $children,
                'level'    => $level,
            ];

            $this->_setItemParams($itemParams);

            if (isset($item['callable']) && is_callable($item['callable'])) {
                $output[] = call_user_func_array($item['callable'], array_merge(['view' => $this->_View], $itemParams));
            } else {
                $output[] = $this->_View->element($options['itemElement'], $itemParams);
            }
        }

        $element = $this->_getCurrentMenuElement($options, $level);

        return $this->_View->element($element, [
            'content' => $output,
            'options' => $options,
        ]);
    }
787030
function(item, parentNode) {
			if (!parentNode) {
				if (!this.domNode) {
					this.show();
				}
				parentNode = this.domNode;
			}
			var addCommand = this.itemConstructMap[item.type || 'item'];
			var node = addCommand.call(this, parentNode, item);
			item.domNode = node;
			this.items.push(item);
			return node;
		}
72303
public function nestedList(array $list, array $options = [], array $itemOptions = [])
    {
        $options = optionsParser($options);
        $itemOptions = optionsParser($itemOptions);

        if ($options->exists('icon')) {
            $itemOptions->add('icon', $options->get('icon'));
        }

        if ($itemOptions->exists('icon')) {
            $options->append('class', 'fa-ul');
            $itemOptions->append('icon', 'li');

            $list = array_map(function ($element) use ($itemOptions) {
                return collection($this->addIconToText($element, clone $itemOptions))->first();
            }, $list);
        }

        $options->delete('icon', 'icon-align');
        $itemOptions->delete('icon', 'icon-align');

        return parent::nestedList($list, $options->toArray(), $itemOptions->toArray());
    }
919799
private function filterParent($parent, MenuItemCollection $items)
    {
        $filteredItems = new MenuItemCollection();

        foreach ($items->getItems() as $name => $item) {
            if ($parent === $item->getParent()) {
                $subItems = $this->filterParent($name, $items);
                if (count($subItems)) {
                    $item->setItems($subItems);
                }
                $filteredItems->set($name, $item);
                $items->remove($name);
            }
        }

        return $filteredItems;
    }
1062301
protected function buildCollapsibleBody($items = [])
    {
        $html[] = Html::beginTag('ul');

        foreach ($items as $item) {
            $url = ArrayHelper::getValue($item, 'url', null);
            $label = ArrayHelper::getValue($item, 'label', '');
            $options = ArrayHelper::getValue($item, 'options', []);
            $link = Html::a($label, $url, $options);
            $html[] = Html::tag('li', $link);
        }

        $html[] = Html::endTag('ul');
        return implode("\n", $html);
    }
996327
protected function _processListItems_callback($matches) {
		$item = $matches[4];
		$leading_line =& $matches[1];
		$leading_space =& $matches[2];
		$marker_space = $matches[3];
		$tailing_blank_line =& $matches[5];

		if ($leading_line || $tailing_blank_line || 
			preg_match('/\n{2,}/', $item))
		{
			// Replace marker with the appropriate whitespace indentation
			$item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
			$item = $this->runBlockGamut($this->outdent($item)."\n");
		} else {
			// Recursion for sub-lists:
			$item = $this->doLists($this->outdent($item));
			$item = $this->formParagraphs($item, false);
		}

		return "<li>" . $item . "</li>\n";
	}
32850
public static function hydrateRecursive(Model $model, array $items, Relation $parentRelation = null)
    {
        $instance = $model;

        $items = array_map(function ($item) use ($instance, $parentRelation) {
            // Convert all null relations into empty arrays
            $item = $item ?: [];
            
            return static::newFromBuilderRecursive($instance, $item, $parentRelation);
        }, $items);

        return $instance->newCollection($items);
    }
274979
public function getChildren(MenuItem $parent = null)
    {
        if ($parent === null) {
            return $this->getTopChildren();
        }
        /* @var $request Request */
        $request = $this->container->get('request_stack')->getCurrentRequest();
        $result = array();
        foreach ($this->getAdaptors() as $menuAdaptor) {
            $menuAdaptor->adaptChildren($this, $result, $parent, $request);
        }

        return $result;
    }
732293
public static function mapDescendantsArray(Tree $parent, Array $map)
    {
        foreach ($map as $item) {
            $node = new static($item);
            $node->setChildOf($parent);
            if (isset($item['children'])) {
                static::mapDescendantsArray($node, $item['children']);
            }
        }

    }
619273
protected function _render($items, $depth = 0)
    {
        $content = '';
        $formatter = $this->config('formatter');

        foreach ($items as $item) {
            $children = '';
            if (is_array($item)) {
                $item = new Entity($item);
            }

            if ($item->has('children') && !empty($item->children) && $item->expanded) {
                $children = $this->formatTemplate('parent', [
                    'attrs' => $this->templater()->formatAttributes([
                        'class' => ($this->config('dropdown') ? 'dropdown-menu multi-level' : ''),
                        'role' => 'menu'
                    ]),
                    'content' => $this->_render($item->children, $depth + 1)
                ]);
            }

            $this->_index++;
            $info = [
                'index' => $this->_index,
                'total' => $this->_count,
                'active' => $this->Link->isActive($item),
                'depth' => $depth,
                'hasChildren' => !empty($children),
                'children' => $children,
            ];
            $content .= $formatter($item, $info);
        }

        return $content;
    }
543417
protected static function createMenuLevel($array, $level, $elements = [], $currentItems = [], $activeClass = 'active', $startLevel = 0, $numLevels = 2){
        $menu = ($level >= $startLevel ? '<ul'.Link::htmlClass($elements['ul_default'].' '.$elements['ul_class'], '').Link::htmlID($elements['ul_id']).'>' : '');
        foreach($array as $item){
            $active = ($currentItems[$level]['uri'] === $item['uri'] ? trim($activeClass) : '');
            $has_child_elements = (is_array($item['children']) && !empty($item['children']) && $level < ($startLevel + $numLevels) ? true : false);
            $menu.= ($level >= $startLevel || $currentItems[$level]['uri'] === $item['uri'] ? ($level < $startLevel && $currentItems[$level]['uri'] === $item['uri'] ? (is_array($item['children']) ? self::createMenuLevel($item['children'], ($level + 1), $elements, $currentItems, $activeClass, $startLevel, $numLevels) : '') : (((isset($item['active']) && boolval($item['active']) === true) || !isset($item['active'])) ? '<li'.Link::htmlClass($elements['li_default'].' '.$item['li_class'], $active).Link::htmlID($item['li_id']).'>'.Link::formatLink($item, $active, $has_child_elements).($has_child_elements ? self::wrapChildren($elements, self::createMenuLevel($item['children'], ($level + 1), $item, $currentItems, $activeClass, $startLevel, $numLevels)) : '').'</li>' : '')) : '');
        }
        $menu.= ($level >= $startLevel ? '</ul>' : '');
        return $menu;
    }
1301896
public static function unorderedList( $items, $level = 0, $attributes = array() )
	{
		$depth1		= 2 * abs( (int) $level );
		$depth2		= $level ? 2 * abs( (int) $level - 1 ) + 1 : 0;
		$indent1	= str_repeat( "  ", $depth1 );
		$indent2	= str_repeat( "  ", $depth2 );
		$content	= "\n".implode( "\n", $items )."\n".$indent1;
		$tag		= UI_HTML_Tag::create( "ul", $content, $attributes );
		$code		= $indent1.$tag."\n".$indent2;
		return $code;
	}
307334
private function buildChannelTree($parentId = self::ROOT_CHANNEL_ID)
    {
        $children = $this->getChildren($parentId);
        $children->map(function (Channel $channel) use ($parentId) {
            $channel->setChildren($this->buildChannelTree($channel->getId()));
            if ($parentId != self::ROOT_CHANNEL_ID) {
                $channel->setParent($this->getChannel($parentId));
            }
        });

        return $children;
    }