src/Data/ModelManipulator.php
public static function updateModelFromPropertyBag(
        PropertiesDefinitionInterface $properties,
        ModelInterface $model,
        PropertyValueBagInterface $values
    ) {
        foreach ($values as $propertyName => $value) {
            try {
                if (!$properties->hasProperty($propertyName)) {
                    continue;
                }

                $property = $properties->getProperty($propertyName);
                $extra    = $property->getExtra();
                // Don´t save value if isset property readonly.
                if (empty($extra['readonly'])) {
                    $model->setProperty($propertyName, static::sanitizeValue($property, $value));
                }

                if (empty($extra)) {
                    continue;
                }

                // If always save is true, we need to mark the model as changed.
                if (!empty($extra['alwaysSave'])) {
                    // Set property to generate alias or combined values.
                    if (!empty($extra['readonly'])) {
                        $model->setProperty($propertyName, static::sanitizeValue($property, null));
                    }

                    $model->setMeta($model::IS_CHANGED, true);
                }
            } catch (\Exception $exception) {
                $values->markPropertyValueAsInvalid($propertyName, $exception->getMessage());
            }
        }
    }
public static function updateModelFromPropertyBag(
        PropertiesDefinitionInterface $properties,
        ModelInterface $model,
        PropertyValueBagInterface $values
    ) {
        foreach ($values as $propertyName => $value) {
            try {
                if (!$properties->hasProperty($propertyName)) {
                    continue;
                }

                $property = $properties->getProperty($propertyName);
                $extra    = $property->getExtra();
                // Don´t save value if isset property readonly.
                if (empty($extra['readonly'])) {
                    $model->setProperty($propertyName, static::sanitizeValue($property, $value));
                }

                if (empty($extra)) {
                    continue;
                }

                // If always save is true, we need to mark the model as changed.
                if (!empty($extra['alwaysSave'])) {
                    // Set property to generate alias or combined values.
                    if (!empty($extra['readonly'])) {
                        $model->setProperty($propertyName, static::sanitizeValue($property, null));
                    }

                    $model->setMeta($model::IS_CHANGED, true);
                }
            } catch (\Exception $exception) {
                $values->markPropertyValueAsInvalid($propertyName, $exception->getMessage());
            }
        }
    }
public static function updateModelFromPropertyBag ( PropertiesDefinitionInterface $ properties , ModelInterface $ model , PropertyValueBagInterface $ values ) { foreach ( $ values as $ propertyName => $ value ) { try { if ( ! $ properties -> hasProperty ( $ propertyName ) ) { continue ; } $ property = $ properties -> getProperty ( $ propertyName ) ; $ extra = $ property -> getExtra ( ) ; // Don´t save value if isset property readonly. if ( empty ( $ extra [ 'readonly' ] ) ) { $ model -> setProperty ( $ propertyName , static :: sanitizeValue ( $ property , $ value ) ) ; } if ( empty ( $ extra ) ) { continue ; } // If always save is true, we need to mark the model as changed. if ( ! empty ( $ extra [ 'alwaysSave' ] ) ) { // Set property to generate alias or combined values. if ( ! empty ( $ extra [ 'readonly' ] ) ) { $ model -> setProperty ( $ propertyName , static :: sanitizeValue ( $ property , null ) ) ; } $ model -> setMeta ( $ model :: IS_CHANGED , true ) ; } } catch ( \ Exception $ exception ) { $ values -> markPropertyValueAsInvalid ( $ propertyName , $ exception -> getMessage ( ) ) ; } } }
Update the model with the values from the value bag.

@param PropertiesDefinitionInterface $properties The property information store.
@param ModelInterface                $model      The model to update.
@param PropertyValueBagInterface     $values     The value bag to retrieve the values from.

@return void
Update the model with the values from the value bag .