Merges existing object items with those coming from database

@param array $items
@param bool $mergeAdded
@return array(eZPageBlockItem)
488741
protected function merge( $items, $mergeAdded = false )
    {
        $itemObjects = array();
        foreach ( $items as $item )
        {
            $oid = $item['object_id'];
            $itemObjects[$oid] = new eZPageBlockItem( $item, false );
        }

        if ( isset( $this->attributes['items'] ) && $this->attributes['items'] )
        {
            foreach ( $this->attributes['items'] as $item )
            {
                $oid = $item->attribute( 'object_id' );
                if ( $item->toBeRemoved() )
                {
                    unset( $itemObjects[$oid] );
                }
                if ( $mergeAdded && $item->toBeAdded() )
                {
                    $itemObjects[$oid] = $item;
                }
                if ( $item->toBeModified() )
                {
                    if ( isset( $itemObjects[$oid] ) )
                    {
                        //modify an item in history to be visible
                        //if item from db is hidden, visible=0 and the item from draft is not, delete it from db queue
                        //this is the case when requesting the history items and valid item
                        if( $item->attribute( 'ts_hidden' ) == 0 && $item->attribute( 'ts_visible' ) == 0 )
                        {
                            if( !$mergeAdded )
                            {
                                unset( $itemObjects[$oid] );
                            }
                        }
                        else
                        {
                            //this is the case when fetching valid items
                            $itemObjects[$oid]->setAttribute( 'ts_publication', $item->attribute( 'ts_publication' ) );
                            $itemObjects[$oid]->setAttribute( 'priority', $item->attribute( 'priority' ) );
                        }
                    }
                    else
                    {
                        //modify an item in history to be visible
                        //if the items from db don't have the item
                        //and modified item is not hidden, add it to the item list.
                        //this is the case when requesting the queue
                        if( $item->attribute( 'ts_hidden' ) == 0 && $item->attribute( 'ts_visible' ) == 0)
                        {
                            if( $mergeAdded )
                            {
                                $itemObjects[$oid] = $item;
                            }
                        }
                    }
                }
            }
        }

        return $itemObjects;
    }
181877
public function mergeWithBinded( $data, $csv = false ) {

		$merge = [];

		if( $csv && strlen( $merge ) > 1 ) {

			$merge = preg_split( '/,/',  $data );
		}

		$this->binded = ArrayHelper::merge( $this->binded, $merge );
	}
83894
public function add( ...$items )
	{
		foreach ( $items as &$item ) $item = (array)$item;
		$this->items = array_merge( $this->items , ...$items );
		return $this;
	}
887033
public function loadFromArray(array $items)
    {
        foreach ($items as $item) {
            if (is_array($item) && ! empty($item)) {
                $this->add($item);
            }
        }

        return $this;
    }
156232
protected function mergeConfigs(array $configs)
    {
        $merged = array();
        foreach ($configs as $config) {
            $merged = array_merge($merged, $config);
        }

        return $merged;
    }
971925
public function add($items)
        {
            if ($items && $items instanceof Container) {
                $id = (int) $items->id;
                $this->_items[$id] = $items;
            } elseif (Arrays::is($items)) {
                foreach ($items as $obj) {
                    if ($obj instanceof Container) {
                        $this->add($obj);
                    }
                }
            } elseif ($items instanceof self) {
                $this->add($items->toArray());
            }

            return $this;
        }
1127258
public static function merge($arrays)
    {
        $merged = [];

        foreach ($arrays as $array)
        {
            $merged = array_merge($merged, static::flatten($array));
        }

        return static::expand($merged);
    }
76901
public function addToArray($items = [])
    {
        if (!is_array($items)) {
            $items = [$items];
        }

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

        return $this;
    }
1006114
public function setItems($items)
    {
        $newItems = new ItemBag();
        foreach ($items as $item) {
            $newItems->add(new Item($item->getParameters()));
        }

        return parent::setItems($newItems);
    }
1002130
public function process(array $items)
    {
        foreach ($items as $key => $item) {
            $items[$key] = $this->doClean($item);
        }

        return $items;
    }
500240
protected function mergeItems() {
        ksort($this->items);
        $this->mergedItems = array();
        foreach ($this->items as $items) {
            $this->mergedItems = array_merge($this->mergedItems, $items);
        }
        return $this;
    }
44112
public function merge($collections = [])
    {
        $collections = func_get_args();

        array_unshift($collections, $this);
        foreach ($collections as &$collection) {
            $collection = (array) $collection;
        }
        unset($collection);

        $merged = call_user_func_array('array_merge', $collections);

        $collections = clone $this;
        $collections->exchangeArray($merged);

        return $collections;
    }
789595
public function filter(array $items): array
    {
        $filtered = [];

        foreach ($items as $sectionName => $sectionDefinition) {
            $isExcluded = true;
            if ($this->shouldSectionBeAdded($sectionName, $sectionDefinition)) {
                $isExcluded = false;
            }
            $sectionDefinition[static::EXCLUDED] = $isExcluded;
            $filtered[$sectionName] = $sectionDefinition;
        }

        return $filtered;
    }
83252
public static function mergeNodes($items1, $items2)
    {
        $ret = array();
        $items = array_merge($items1, $items2);
        $len = count($items);

        // collects non-repeated elements
        for ($i = 0; $i < $len; $i++) {
            $item = $items[$i];
            $position = Dom::searchNode($item, $items, $i + 1);
            if ($position === false) {
                array_push($ret, $item);
            }
        }
        
        return $ret;
    }
93931
public function fillItems(array &$rows = null)
    {
        if ($rows === null) {
            return $this->load();
        }

        $this->clearItems();
        foreach ($rows as $row) {
            $item = $this->instantiateItem($row);
            $this->addItem($item);
        }

        return true;
    }
1258251
public function add($items = [])
    {
        if (!is_array($items) || func_num_args() > 1) {
            $items = func_get_args();
        }

        $this->push($this->formatInnerField(null, $items));
    }
1227742
public function addItems(array $items, $where = '')
    {
        foreach (array_keys($items) as $k) {
            if (!is_int($k) && $this->hasItem($k)) {
                unset($items[$k]);
            }
        }
        if (!empty($items)) {
            $this->setItems($items, $where);
        }

        return $this;
    }