src/Charcoal/Model/AbstractModel.php
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;
    }
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;
    }
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 ; }
Merge data on the model.

Overrides `\Charcoal\Config\AbstractEntity::setData()`
to take properties into consideration.

Also add a special case, to merge values for l10n properties.

@param  array $data The data to merge.
@return self
Merge data on the model .