@param MenuItemCollection $items

@return $this
548655
public function merge(MenuItemCollection $items)
    {
        foreach ($items->getItems() as $name => $item) {
            $this->set($name, $item);
        }

        return $this;
    }
1363458
protected function formatMenuItems(&$items)
    {
        foreach ( $items as $key => $item ) {
            $itemData = array_only($item->toArray(), $this->selectFields);

            if( ! $item->children->isEmpty() ) {
                $itemData['children'] = $this->sortByField(
                    $this->formatMenuItems($item->children)
                );
            }

            $items[$key] = $itemData;
        }

        return $items;
    }
766209
public function setDisabledItems($items)
    {
        $controller = Controller::curr();
        $code = $controller->data()->Code;
        $updated = [];
        if (is_array($items) && !empty($items)) {
            foreach ($items as $item) {
                array_push($updated, ProductPage::getGeneratedValue($code, $this->getName(), $item, 'value'));
            }
        }
        $this->disabledItems = $updated;

        return $this;
    }
732478
public static function createMenuItem(array $item): MenuItemInterface
    {
        $menuItem = static::_getMenuItemObject($item);
        foreach ($item as $key => $value) {
            if ($key == 'children') {
                foreach ($value as $k => $v) {
                    $childItem = static::createMenuItem($v);
                    $menuItem->addMenuItem($childItem);
                }
            } elseif ($key == 'attributes') {
                foreach ($value as $k => $v) {
                    $menuItem->addAttribute($k, $v);
                }
            } elseif ($key == 'viewElement') {
                call_user_func_array([$menuItem, 'setViewElement'], $value);
            } else {
                $method = 'set' . ucfirst(Inflector::camelize($key));
                if (method_exists($menuItem, $method)) {
                    $menuItem->$method($value);
                }
            }
        }

        return $menuItem;
    }
221594
public function setItems(array $items)
    {
        $this->content = new HtmlElements();

        foreach ($items as $item) {
            $this->addItem($item);
        }

        return $this;
    }
218641
public function setItems(array $items)
    {
        $items = $this->getArrayableItems($items);

        foreach ($items as $item) {
            //Ensure the correct type is provided
            $this->checkType($item);
        }

        $this->items = $items;

        return $this;
    }
1137458
public function setItems($items)
    {
        $orderItems = [];
        foreach ($items as $item) {
            if (is_array($item)) {
                $orderItems[] = new Item($item);
            } elseif (! ($item instanceof Item)) {
                throw new \InvalidArgumentException('Item should be an instance of ' . Item::class);
            }
        }

        return parent::setItems($orderItems);
    }
84910
public function setItems(Parameter $items = null)
    {
        if ($this->items = $items) {
            $this->items->setParent($this);
        }

        return $this;
    }
1283629
public function addFeedableItems($items)
    {
        if (!is_array($items) && !($items instanceof \Traversable)) {
            throw new \InvalidArgumentException('You should pass an array or a collection of Feedable items');
        }

        foreach ($items as $feedable) {
            if (!$feedable instanceof Feedable) {
                throw new \InvalidArgumentException('Feedable items should implement Feedable interface');
            }

            $this->addItem($feedable->getFeedItem());
        }

        return $this;
    }
486952
protected function saveMenuItems(Menu $menu, $items)
    {
        $itemStorage  = $this->treeManager->getItemStorage();
        $currentTree  = $this->treeManager->buildTree($menu->getId(), false);
        $menuId       = $menu->getId();

        // First, get all elements so that we can delete those that are removed
        // @todo pri: sorry this is inneficient, but I need it
        $old = [];
        foreach ($currentTree->getAll() as $item) {
            $old[$item->getId()] = $item;
        }

        // FIXME, this is coming from javascript, we should really check access on nodes

        // Keep a list of processed elements
        $processed = [];
        $deleteItems = [];

        // Keep in mind that items ordered
        if (!empty($items)) {

            // Because they are ordered and a parent will be saved before a child,
            // thus modifying a child: we have to use a classic loop
            $itemsCount = count($items);

            // Keep track of latest root parent found, in order to reorder top
            // level item relative to each other.
            $latestRootParentId = null;

            for ($i = 0; $i < $itemsCount; $i++) {

                $item     = $items[$i];
                $nodeId   = $item['item_id'];
                $isNew    = substr($item['id'], 0, 4) == 'new_' || empty($item['id']);
                $title    = trim($item['title']);
                $itemId   = $isNew ? null : $item['id'];
                $parentId = empty($item['parent_id']) ? null : $item['parent_id'];

                if ($isNew) {
                    if ($parentId) {
                        $itemId = $itemStorage->insertAsChild($parentId, $nodeId, $title);
                    } else {
                        $itemId = $itemStorage->insert($menuId, $nodeId, $title);
                        // Move the new item, in root tree, right after the
                        // lastest processed root item
                        if ($latestRootParentId) {
                            $itemStorage->moveAfter($itemId, $latestRootParentId);
                        }
                    }
                    // New potential parent item inserted, replace potential children parent_id
                    foreach ($items as $index => $potentialChild) {
                        if ($potentialChild['parent_id'] === $item['id']) {
                            $items[$index]['parent_id'] = $itemId;
                        }
                    }
                } else {
                    if ($parentId) {
                        $itemStorage->moveAsChild($itemId, $parentId);
                    } else {
                        if ($latestRootParentId) {
                            $itemStorage->moveAfter($itemId, $latestRootParentId);
                        } else {
                            $itemStorage->moveToRoot($itemId);
                        }
                    }

                    // When inserting or moving an item in the root of the tree
                    // we must keep track of it for being able to properly place
                    // the item relatively to its previous sibling.
                    if (!$parentId) {
                        $latestRootParentId = $itemId;
                    }

                    // Update title if revelant
                    if ($title !== $currentTree->getItemById($itemId)->getTitle()) {
                        $itemStorage->update($itemId, null, $title);
                    }
                }

                $processed[$itemId] = true;
            }
        }

        $newTree = $this->treeManager->buildTree($menuId, false, false, true);

        // Remove elements not in the original array
        foreach (array_diff_key($old, $processed) as $itemId => $deleted) {
            $itemStorage->delete($itemId);
            $deleteItems[$itemId] = $deleted;
        }

        $this->dispatcher->dispatch(
            MenuEvent::EVENT_TREE,
            new MenuEvent(
                $menu->getName(),
                $newTree,
                $deleteItems,
                $menu->hasSiteId() ? $this->siteManager->getStorage()->findOne($menu->getSiteId()) : null
            )
        );
    }
949718
public function add(array $items) {
		
		foreach($items as $name => $object) {
			$this->set($name, $object);
		}
		
		return $this;
	}
246835
public function insertArray(array $items)
    {
        foreach ($items as $priority => $item) {
            $this->insert($item, $priority);
        }

        return $this;
    }
1343737
public function add(... $items) : Set
    {
        $values = $this->_pushAll($items);
        $this->setValues($values);
        return $this;
    }
1004126
public function add($items)
    {
        if (is_array($items)) {
            $this->collection[] = new Record($items);
        } elseif (is_object($items) && $items instanceof Record) {
            $this->collection[] = $items;
        }

        return $this;
    }
1363666
public function add(MenuItem $item)
    {
        $this->collection[$this->count] = $item;
        $this->names[$item->getName()]  = $this->count;

        $this->count++;

        return $this;
    }
228466
public function add($items)
    {
        if (is_array($items)) {
            $this->collection[] = new Delta($items);
        } elseif (is_object($items) && $items instanceof Delta) {
            $this->collection[] = $items;
        }

        return $this;
    }
57214
protected function convertItems($items)
    {
        $convertedItems = new Collection();

        foreach ($items as $item) {
            $convertedItems->add(new ItemContainer($item));
        }

        return $convertedItems;
    }