Normalizes the [[items]] property to remove invisible items and activate certain items.

@param array $items  the items to be normalized.
@param bool  $active whether there is an active child menu item.

@return array the normalized menu items
546902
protected function normalizeItems($items, &$active)
    {
        foreach ($items as $i => $item) {
            if (isset($item['visible']) && !$item['visible']) {
                unset($items[$i]);
                continue;
            }
            if (!isset($item['label'])) {
                $item['label'] = '';
            }
            $encodeLabel = $item['encode'] ?? $this->encodeLabels;
            $items[$i]['label'] = $encodeLabel ? Html::encode($item['label']) : $item['label'];
            $hasActiveChild = false;
            if (isset($item['items'])) {
                $items[$i]['items'] = $this->normalizeItems($item['items'], $hasActiveChild);
                if (empty($items[$i]['items']) && $this->hideEmptyItems) {
                    unset($items[$i]['items']);
                    if (!isset($item['url'])) {
                        unset($items[$i]);
                        continue;
                    }
                }
            }
            if (!isset($item['active'])) {
                if ($this->activateParents && $hasActiveChild || $this->activateItems && $this->isItemActive($item)) {
                    $active = $items[$i]['active'] = true;
                } else {
                    $items[$i]['active'] = false;
                }
            } elseif ($item['active'] instanceof Closure) {
                $active = $items[$i]['active'] = call_user_func($item['active'], $item, $hasActiveChild, $this->isItemActive($item), $this);
            } elseif ($item['active']) {
                $active = true;
            }
        }

        return array_values($items);
    }
887033
public function loadFromArray(array $items)
    {
        foreach ($items as $item) {
            if (is_array($item) && ! empty($item)) {
                $this->add($item);
            }
        }

        return $this;
    }
118618
protected function renderSubItems($items, &$active)
    {
        $subItems = [];

        foreach ($items as $i => $item) {
            if (isset($item['visible']) && !$item['visible']) {
                continue;
            }
            $item['icon'] = 'fa fa-caret-right';


            if (ArrayHelper::keyExists('items', $item)) {
                $subActive = false;
                $subItems[] = $this->renderDropDownItem($item,$subActive);
                $active = $active || $subActive;
            } else {
                $subItems[] = $this->renderItem($item);
            }
        }


        return Html::tag('ul', implode("\n", $subItems), ['class' => 'submenu']);
    }
8227
public function filter(array $items): array
    {
        foreach ($this->filter as $filter) {
            $items = $filter->filter($items);
        }

        return $items;
    }
278545
protected function makeTree(array &$items)
    {
        $result = [];
        $tops = [];

        /**
         * @var Entity $item
         */
        foreach ($items as $item) {
            $result[$item->getKey()] = $item;
        }

        foreach ($items as $item) {
            $parentId = $item->{$item->getParentIdColumn()};

            if (array_key_exists($parentId, $result)) {
                $result[$parentId]->appendRelation($item->getChildrenRelationIndex(), $item);
            } else {
                $tops[] = $item;
            }
        }

        return $tops;
    }
1225065
public function removeChildren(array $items): bool
    {
        if ($this->_item !== null) {
            foreach ($items as $name) {
                $child = $this->manager->getPermission($name);
                if (empty($child) && $this->type == Item::TYPE_ROLE) {
                    $child = $this->manager->getRole($name);
                }
                $this->manager->removeChild($this->_item, $child);
            }
        }

        return true;
    }
24702
public function process(array $items)
    {
        if (!$this->limit) {
            return $items;
        }
        $total = count($items);
        if ($this->limit > $total) {
            return $items;
        }
        for ($i = $this->limit; $i < $total; $i++) {
            if (isset($items[$i])) {
                unset($items[$i]);
            }
        }

        return $items;
    }
447915
public function process(array $items)
    {
        foreach ($items as $key => $item) {
            $items[$key] = $this->setImages($item);
        }

        return $items;
    }
404394
protected function filterItemsForNotPossibleMinifiedAndPossibleMinifiedItems ($items) {
		$itemsToRenderMinimized = [];
		$itemsToRenderSeparately = []; // some configurations is not possible to render together and minimized
		// go for every item to complete existing combinations in attributes
		foreach ($items as & $item) {
			$itemArr = array_merge((array) $item, []);
			unset($itemArr['path']);
			if (isset($itemArr['render'])) unset($itemArr['render']);
			if (isset($itemArr['external'])) unset($itemArr['external']);
			$renderArrayKey = md5(json_encode($itemArr));
			if ($itemArr['doNotMinify']) {
				if (isset($itemsToRenderSeparately[$renderArrayKey])) {
					$itemsToRenderSeparately[$renderArrayKey][] = $item;
				} else {
					$itemsToRenderSeparately[$renderArrayKey] = [$item];
				}
			} else {
				if (isset($itemsToRenderMinimized[$renderArrayKey])) {
					$itemsToRenderMinimized[$renderArrayKey][] = $item;
				} else {
					$itemsToRenderMinimized[$renderArrayKey] = [$item];
				}
			}
		}
		return [
			$itemsToRenderMinimized,
			$itemsToRenderSeparately,
		];
	}
435640
private function createModelCollectionFromActions(array $actions, array &$items)
    {
        $models = new DefaultCollection();
        foreach ($actions as $action) {
            $models->push($action['model']);
            $items[] = $action['item'];
        }

        return $models;
    }
239053
public function reset($items = null)
    {
        $this->items = [];
        if ((func_get_args() > 0) && is_array($items)) {
            $this->items = $items;
        }
        return $this;
    }
1366525
public function removeAll(array $items) : Set
    {
        $values = $this->_removeSameAll($items);
        $this->setValues($values);
        return $this;
    }
2225
public function merge(array $items)
    {
        $this->items = $this->arrayMergeRecursive($this->items, $items);
        $this->nestedKeyCache = [];
    }
1066839
public function prepareItems($items)
    {
        if (!is_array($items)) {
            return $items;
        } elseif (self::isAssoc($items)) {
            $items = $this->prepareItem($items);
        } else {
            foreach ($items as $key => $item) {
                $items[ $key ] = $this->prepareItem($item);
            }
        }
        return $items;
    }
440475
public static function menuToRules($items)
    {
        $rules = [];
        foreach ($items as $item) {
            $url = ArrayHelper::getValue($item, 'url');
            $urlRule = ArrayHelper::getValue($item, 'urlRule');

            if ($url && $urlRule && is_array($url)) {
                $defaults = $url;
                $route = array_shift($defaults);

                if (is_string($urlRule)) {
                    $rules[] = [
                        'pattern' => Yii::getAlias($urlRule),
                        'route' => $route,
                    ];
                } elseif (is_array($urlRule)) {
                    if (!isset($urlRule['route'])) {
                        $urlRule['route'] = $route;
                    }
                    $rules[] = $urlRule;
                }
            }

            $subItems = ArrayHelper::getValue($item, 'items');
            if (is_array($subItems)) {
                $rules = array_merge(static::menuToRules($subItems), $rules);
            }
        }
        return $rules;
    }
871578
public function mergeMenus(array $items)
    {
        foreach ($items as $item) {
            $menu = Yii::createObject($item['menu']);
            $this->mergeItems($menu->getItems());
        }
    }
193564
public function setSelectionItems(array $items)
    {
        $this->selectionItems = $items;

        $this->model->selectionItems = $this->getCurrentlyAvailableSelectionItems();

        return $this;
    }