渲染所以项目
@param $items
@return null|string
@throws InvalidConfigException
434932
public function renderItems($items)
    {
        if (is_string($items)) {
            return $items;
        }
        $lines = [];
        foreach ($items as $item) {
            if (is_string($item)) {
                return $item;
            }
            if (!isset ($item['label'])) {
                throw new InvalidConfigException ("The 'label' option is required.");
            }
            $encodeLabel = isset ($item['encode']) ? $item['encode'] : $this->encodeLabels;

            if ($item['parent'] == null) {//如果是顶级菜单
                $item['label'] = $encodeLabel ? Html::tag('span', Html::encode($item['label']), ['class' => 'nav-label']) : $item['label'];
            } else {
                $item['label'] = $encodeLabel ? Html::encode($item['label']) : $item['label'];
            }

            $item['icon'] = isset ($item['icon']) ? Html::tag('i', '', ['class' => 'fa fa-lg fa-fw ' . $item['icon']]) : '';

            $options = ArrayHelper::getValue($item, 'options', []);
            $subItems = ArrayHelper::getValue($item, 'items');
            if (isset ($item['active'])) {
                $active = ArrayHelper::remove($item, 'active', false);
            } else {
                $active = $this->isItemActive($item);
            }
            //判断是否有子菜单
            if ($subItems !== null && is_array($subItems)) {
                if ($this->activateItems) {
                    $subItems = $this->isChildActive($subItems, $active);
                    if ($active) { //如果被激活则父菜单是打开状态
                        Html::addCssClass($options, 'active');
                    }
                }

                $subItems = $this->renderItems($subItems);
                if($subItems){
                    $submenuTemplate = ArrayHelper::getValue($item, 'submenuTemplate', $this->submenuTemplate);
                    $subItems = strtr($submenuTemplate, [
                        '{items}' => $this->renderItems($subItems),
                    ]);
                }

            }
            if ($this->activateItems && $active) {//无子菜单则激活当前菜单
                Html::addCssClass($options, 'active');
            }
            if (isset ($item['visible']) && !$item['visible']) {
                continue;
            }
            if ($subItems == null) {
                Html::removeCssClass($options, 'open');
            }
            $menu = $this->renderItem($item);
            $lines[] = Html::tag('li', $menu . $subItems, $options);
        }
        if (empty($lines)) {
            return null;
        }
        return implode("\n", $lines);
    }
492449
public function printItems(...$items)
    {
        $args = func_get_args();

        if (count($args) == 0) {
            $args = $this->items;
        }

        for ($i = 0; $i < sizeof($args); $i++) {
            $data = $args[$i];

            if (is_array($data)) {
                $this->printLabelValuePairs($data);
            } elseif (is_object($data)) {
                print $data;
            } else {
                $value = $this->generateValue($data);

                if ($value !== false && $value !== null) {
                    print $value;
                } else {
                    print $this->parseStringAsTemplate($data);
                }
            }
        }
    }
508204
public function export(array $items = null)
    {
        if (empty($items)) {
            $items = $this->getItems();
        }

        $data = $this->getDataByItems($items);

        return $this->save($this->headers, $data);
    }
691990
public function createMany(array $items)
    {
        $models = collection();

        foreach ($items as $item) {
            $models[] = $this->create($item);
        }

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

        return $this;
    }
239136
public function rebuildIndex( array $items = array() )
	{
		$context = $this->_getContext();
		$config = $context->getConfig();

		$size = $config->get( 'mshop/catalog/manager/index/default/chunksize', 1000 );
		$mode = $config->get( 'mshop/catalog/manager/index/default/index', 'categorized' );

		$default = array( 'attribute', 'price', 'text', 'product' );
		$domains = $config->get( 'mshop/catalog/manager/index/default/domains', $default );

		$manager = MShop_Factory::createManager( $context, 'product' );
		$search = $manager->createSearch( true );
		$search->setSortations( array( $search->sort( '+', 'product.id' ) ) );
		$defaultConditions = $search->getConditions();

		$paramIds = array();
		foreach( $items as $item ) {
			$paramIds[] = $item->getId();
		}

		if( $mode === 'all' ) // index all product items
		{
			if( !empty( $paramIds ) )
			{
				$expr = array(
					$search->compare( '==', 'product.id', $paramIds ),
					$defaultConditions,
				);
				$search->setConditions( $search->combine( '&&', $expr ) );
			}

			$this->_writeIndex( $search, $domains, $size );
			return;
		}

		// index categorized product items only
		$catalogListManager = MShop_Factory::createManager( $context, 'catalog/list' );
		$catalogSearch = $catalogListManager->createSearch( true );

		$expr = array( $catalogSearch->compare( '==', 'catalog.list.domain', 'product' ) );

		if( !empty( $paramIds ) ) {
			$expr[] = $catalogSearch->compare( '==', 'catalog.list.refid', $paramIds );
		}

		$expr[] = $catalogSearch->getConditions();

		$catalogSearch->setConditions( $catalogSearch->combine( '&&', $expr ) );
		$catalogSearch->setSortations( array( $catalogSearch->sort( '+', 'catalog.list.refid' ) ) );

		$start = 0;

		do
		{
			$catalogSearch->setSlice( $start, $size );
			$result = $catalogListManager->aggregate( $catalogSearch, 'catalog.list.refid' );

			$expr = array(
				$search->compare( '==', 'product.id', array_keys( $result ) ),
				$defaultConditions,
			);
			$search->setConditions( $search->combine( '&&', $expr ) );

			$this->_writeIndex( $search, $domains, $size );

			$start += $size;
		}
		while( count( $result ) > 0 );
	}
1041980
public function addChildren($items)
    {
        $manager = Configs::authManager();
        $success = 0;
        if ($this->_item) {
            foreach ($items as $name) {
                $child = $manager->getPermission($name);
                if ($this->type == Item::TYPE_ROLE && $child === null) {
                    $child = $manager->getRole($name);
                }
                try {
                    $manager->addChild($this->_item, $child);
                    $success++;
                } catch (\Exception $exc) {
                    Yii::error($exc->getMessage(), __METHOD__);
                }
            }
        }
        if ($success > 0) {
            Helper::invalidate();
        }
        return $success;
    }
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;
    }
935933
protected function setItemListElementAttribute($items)
    {
        foreach($items as $pos=>$item) {
            $items[$pos] = $this->getNestedContext(ListItem::class, [
                'position' => $pos + 1,
                'item' => $item
            ]);
        }

        return $items;
    }
847906
public function add ($item) {
        if ($this->name === null) {
            throw new InvalidConfigException(get_class ($this) . " requires a name!");
        }
        if (!$this->getConnection ()->getClient ()->rpush ($this->name , $item)) {
            return false;
        }
        $this->_data = null;
        $this->_count = null;
        return true;
    }
463669
protected function getItemsAsArray($items)
    {
        if (is_array($items)) {
            return $items;
        } elseif ($items instanceof self) {
            return $items->all();
        } elseif ($items instanceof Traversable) {
            return iterator_to_array($items);
        }

        return (array) $items;
    }
102857
public function getConfig( string...$keys )
	{
		$result= $this->config;

		foreach( $keys as $key ){
			if( !isset($result[$key]) )
				{ return null; }

			$result= $result[$key];
		}

		return $result;
	}
768296
public function setItems($items)
    {
        foreach ($this->items as $item) {
            $item->setOrder(null);
        }
        foreach ($items as $item) {
            $item->setOrder($this);
        }
        $this->items = $items;
        return $this;
    }
617971
protected function load(array $files = null)
    {
        $defaults = [
            'bindings' => null,
            'providers' => null,
            'minimal' => null,
            'config' => null,
            'subscribers' => null,
            'routes' => null,
            'modules' => null
        ];

        is_array($files) ? extract($files) : extract($defaults);

        $bindings = isset($bindings) ? $bindings : null;
        ArrayLoader::bindings(Config::paths('system') . $bindings);

        $providers = isset($providers) ? $providers : null;
        ArrayLoader::providers(Config::paths('system') . $providers);

        $minimal = isset($minimal) ? $minimal : null;
        ArrayLoader::config(Config::paths('system') . $minimal);

        $config = isset($config) ? $config : null;
        ArrayLoader::config(Config::paths('system') . $config);

        $subscribers = isset($subscribers) ? $subscribers : null;
        ArrayLoader::subscribers(Config::paths('system') . $subscribers);

        $routes = isset($routes) ? $routes : null;
        ArrayLoader::routes(Config::paths('system') . $routes);

        $modules = isset($modules) ? $modules : null;
        ArrayLoader::modules(Config::paths('system') . $modules);

    }
1033618
public function order($items)
	{
		$this->emptyResult();

		empty($items) ? $this->queryBuilder->order(NULL) : $this->queryBuilder->addOrder(func_get_args());
		return $this;
	}
721318
protected function renderItems($items)
	{
		$script = '';
		foreach ($items as $key => $item)
		{
			if(is_array($item))
			{
				$script = $script."'$key':[";
				foreach ($item as $value)
					$script = $script."'$value',";
				$script = $script."],";
			} else
				$script = $script."'$key':'$item',";
		}
		return $script;
	}
587857
public function generateTree($items)
    {
        foreach ($items->reverse()->all() as $index => $item) {
            $parent = $this->findParent($items, $item);

            if (isset($parent)) {
                $parent->setChild($item);

                $items->forget($index);
            }
        }

        return $items;
    }