Merges an item into given data.

@param array $data Data to merge item into.
@param array $item Item to merge into $data. The item must have an `'id'` key.
@return array The merged data.
480634
protected function _merge(array $data, array $item) {
		if (!isset($item['id'])) {
			return $data;
		}
		$id = $item['id'];

		$defaults = [
			'ids' => [],
			'translated' => null,
			'flags' => [],
			'comments' => [],
			'occurrences' => []
		];
		$item += $defaults;

		if (isset($item['context']) && $item['context']) {
			$id .= '|' . $item['context'];
		}

		if (!isset($data[$id])) {
			$data[$id] = $item;
			return $data;
		}
		foreach (['ids', 'flags', 'comments', 'occurrences'] as $field) {
			$data[$id][$field] = array_merge($data[$id][$field], $item[$field]);
		}
		if (!isset($data[$id]['translated'])) {
			$data[$id]['translated'] = $item['translated'];
		} elseif (is_array($item['translated'])) {
			$data[$id]['translated'] = (array) $data[$id]['translated'] + $item['translated'];
		}
		return $data;
	}
487665
public function addItem($item)
    {
        if (!$this->getItems()) {
            return $this->setItems(array($item));
        } else {
            return $this->setItems(
                array_merge($this->getItems(), array($item))
            );
        }
    }
717034
function mergeWith($data = [])
    {
        if (is_array($data) || is_object($data))
            foreach ($data as $key => $value) {
                $this->__data->{$key} = $value;
            }
        return $this;
    }
1253975
public function data(array $data)
    {
        if (!is_array($this->props['data'])) $this->props['data'] = [];
        $this->props['data'] = array_merge($this->props['data'], $data);
        return $this;
    }
1153203
public function deserialize(array $data, Item $item = null, array $options = [])
    {
        return $this->serializer->deserialize($data, $item, $options);
    }
766199
private function createDataItems(array $data)
    {
        $items = [];
        foreach ($data as $item) {
            $items[$item['label']] = new UserDataItem(
                $item['label'],
                $item['value'],
                $item['isValid'],
                $item['isOwner']
            );
        }

        return $items;
    }
940291
public static function includeInArray($item, $array)
    {
        if (self::isItemOrderInvalid($item, $array)) {
            return array_merge($array, [$item['name'] => $item['content']]);
        }

        $count = 0;
        $last  = $array;
        $first = [];
        foreach ($array as $key => $value) {
            if ($count == $item['order']) {
                return array_merge($first, [$item['name'] => $item['content']], $last);
            }

            unset($last[$key]);
            $first[$key] = $value;

            $count++;
        }
    }
1121076
public static function add($key = null, $data = [])
    {
        // If no key is given
        if (is_null($key)) {
            // Set key to file and line
            $key = Debugger::getCalledFrom(2);
        }

        // If key is allready in use
        if (isset(self::$collection[$key])) {
            // Get original item
            $item = self::$collection[$key];

            // Set new item count
            $itemCount = (isset($item['count']) ? ($item['count'] + 1) : 2);

            // Set correct key for the original item
            if (strpos($item['key'], '#') === false) {
                self::$collection[$key] = array_merge($item, [
                    'key'   => $key . ' #1',
                    'count' => $itemCount,
                ]);
            } else {
                self::$collection[$key] = array_merge($item, [
                    'count' => $itemCount,
                ]);
            }

            // Set new key
            $key = $key . ' #' . $itemCount;
        }

        // Make sure various options are set
        if (!isset($data['key'])) {
            $data['key'] = $key;
        }
        if (!isset($data['parent'])) {
            $data['parent'] = self::$currentItem;
        }
        if (!isset($data['level'])) {
            $data['level'] = 0;
            if (isset($data['parent']) && isset(self::$collection[$data['parent']])) {
                $data['level'] = (self::$collection[$data['parent']]['level'] + 1);
            }
        }

        // Add item to collection
        self::$collection[$key] = $data;

        return $key;
    }
444742
public function addItems($data)
	{
		if( is_null($data) )
		{
			return;
		}

		if( $data instanceof stdClass )
		{
			$data = [$data];
		}

		if( is_array($data) )
		{
			$data = $this->checkItems($data);
			$this->data = array_merge($this->data, $data);
		}
	}
154175
public function merge($data)
	{
		foreach ($data as $key => $value) {
			$this->set($key, $value);
		}
	}
1059212
private function _merge(array $data) : array
    {
        $values = $this->getValues();
        $values = array_merge($values, $data);
        return $values;
    }
1040285
public function merge($items)
    {
        if ($items instanceof ArrayInterface) {
            $this->items = array_merge($this->items, $items->all());
        } else {
            $this->items = array_merge($this->items, $items);
        }

        return $this;
    }
1009111
public function merge(array $data)
    {
        $this->items = $this->blueprints()->mergeData($this->items, $data);

        return $this;
    }
1270859
public function mergeData(array $data)
    {
        $data = $this->setIdFromData($data);

        foreach ($data as $propIdent => $val) {
            if (!$this->hasProperty($propIdent)) {
                $this->logger->warning(sprintf(
                    'Cannot set property "%s" on object; not defined in metadata.',
                    $propIdent
                ));
                continue;
            }

            $property = $this->p($propIdent);
            if ($property->l10n() && is_array($val)) {
                $currentValue = json_decode(json_encode($this[$propIdent]), true);
                if (is_array($currentValue)) {
                    $this[$propIdent] = array_merge($currentValue, $val);
                } else {
                    $this[$propIdent] = $val;
                }
            } else {
                $this[$propIdent] = $val;
            }
        }

        return $this;
    }
139619
public function add_data(array $data)
	{
		$ar = \func_get_args();
		foreach ( $ar as $d ){
			if ( \is_array($d) ){
				$this->data = $this->has_data() ? array_merge($this->data,$d) : $d;
			}
		}
		return $this;
	}
1203192
protected function prepareItem(array $item, array $data)
    {
        $product = $this->product->getBySku($item['sku'], $item['store_id']);

        if (empty($product['status']) || $data['store_id'] != $product['store_id']) {
            return array();
        }

        $product['price'] = $this->currency->convert($product['price'], $product['currency'], $data['currency']);

        $calculated = $this->product->calculate($product);

        if ($calculated != $product['price']) {
            $item['original_price'] = $product['price'];
        }

        $item['product'] = $product;
        $item['price'] = $calculated;
        $item['total'] = $item['price'] * $item['quantity'];

        return $item;
    }
874965
public function mergeData(array $data)
    {
        $args = func_get_args();
        foreach ($args as $key => $v) {
            if (is_array($v)) {
                $this->data = array_merge($this->data, $v);
            }
        }
    }