Converts data from $value to $storageFieldValue.

@param \eZ\Publish\SPI\Persistence\Content\FieldValue $value
@param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $storageFieldValue
178855
public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
    {
        $storageFieldValue->dataText = isset($value->data['text'])
            ? $value->data['text']
            : null;
        $storageFieldValue->dataInt = isset($value->data['urlId'])
            ? $value->data['urlId']
            : null;
    }
1358667
public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
    {
        if (isset($value->data)) {
            // Determine what needs to be stored
            if (isset($value->data['width']) && isset($value->data['fieldId'])) {
                // width + field id set means that something really needs to be stored
                $storageFieldValue->dataText = $this->createLegacyXml($value->data);
            } elseif (isset($value->data['fieldId'])) {
                // $fieldId without width mleans an empty field
                $storageFieldValue->dataText = $this->createEmptyLegacyXml($value->data);
            }
            // otherwise the image is unprocessed and the DB field stays empty
            // there will be a subsequent call to this method, after the image
            // has been stored
        }
    }
463774
public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
    {
        $fieldValue->data = [
            'destinationContentId' => $value->dataInt ?: null,
        ];
        $fieldValue->sortKey = (int)$value->sortKeyInt;
    }
981668
public function SetValue($FieldName, $Value) {
      if (!is_array($this->_DataArray))
         $this->_DataArray = array();
      
      $this->_DataArray[$FieldName] = $Value;
   }
291327
public function updateNonTranslatableField(
        Field $field,
        StorageFieldValue $value,
        $contentId
    ) {
        try {
            return $this->innerGateway->updateNonTranslatableField($field, $value, $contentId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
950179
public function handleField(FieldValue $value, Closure $next): FieldValue
    {
        $this->setNodeKey(
            $value->getParent()
        );

        $value = $next($value);
        $resolver = $value->getResolver();
        $maxAge = $this->directiveArgValue('maxAge');
        $privateCache = $this->directiveArgValue('private', false);

        return $value->setResolver(function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) use ($value, $resolver, $maxAge, $privateCache) {
            $cacheValue = new CacheValue([
                'field_value' => $value,
                'root' => $root,
                'args' => $args,
                'context' => $context,
                'resolve_info' => $resolveInfo,
                'private_cache' => $privateCache,
            ]);

            $cacheKey = $cacheValue->getKey();
            $cacheTags = $cacheValue->getTags();

            /** @var \Illuminate\Cache\CacheManager $cache */
            $cache = app('cache');
            $useTags = $this->useTags($cache);

            $cacheHas = $useTags
                ? $cache->tags($cacheTags)->has($cacheKey)
                : $cache->has($cacheKey);

            if ($cacheHas) {
                return $useTags
                    ? $cache->tags($cacheTags)->get($cacheKey)
                    : $cache->get($cacheKey);
            }

            $resolvedValue = $resolver($root, $args, $context, $resolveInfo);

            $cacheExp = $maxAge
                ? Carbon::now()->addSeconds($maxAge)
                : null;

            ($resolvedValue instanceof Deferred)
                ? $resolvedValue->then(function ($result) use ($cache, $cacheKey, $cacheExp, $cacheTags): void {
                    $this->store($cache, $cacheKey, $result, $cacheExp, $cacheTags);
                })
                : $this->store($cache, $cacheKey, $resolvedValue, $cacheExp, $cacheTags);

            return $resolvedValue;
        });
    }
896655
public function serializeSaveField(Field $f, $value)
    {
        try {
            // use $f->serialize = [encode_callback, decode_callback]
            if (is_array($f->serialize) && isset($f->serialize[0]) && is_callable($t = $f->serialize[0])) {
                return $t($f, $value, $this);
            }

            // run persistence-specific serialization of field value
            return $this->_serializeSaveField($f, $value);
        } catch (\Exception $e) {
            throw new Exception(['Unable to serialize field value on save', 'field' => $f->name], null, $e);
        }
    }
177685
public function verifyFieldHasValue(string $fieldName, $value, ?string $containerName = null): void
    {
        $fieldElement = $this->getField($fieldName, $containerName);
        Assert::assertEquals(
            $value,
            $fieldElement->getValue(),
            'Field has wrong value'
        );
    }
1042268
protected function _setFieldValue($field, $value)
    {
        // ignore setting versioning fields
        if (static::isVersioned()) {
            if (array_key_exists($field, static::$versioningFields)) {
                return false;
            }
        }

        if (!static::fieldExists($field)) {
            return false;
        }
        $fieldOptions = static::$_classFields[get_called_class()][$field];

        // no overriding autoincrements
        if ($fieldOptions['autoincrement']) {
            return false;
        }

        // pre-process value
        $forceDirty = false;
        switch ($fieldOptions['type']) {
            case 'clob':
            case 'string':
            {
                $value = $this->_setStringValue($fieldOptions, $value);
                break;
            }

            case 'boolean':
            {
                $value = $this->_setBooleanValue($value);
                break;
            }

            case 'decimal':
            {
                $value = $this->_setDecimalValue($value);
                break;
            }

            case 'int':
            case 'uint':
            case 'integer':
            {
                $value = $this->_setIntegerValue($fieldOptions, $value);
                break;
            }

            case 'timestamp':
            {
                $value = $this->_setTimestampValue($value);
                break;
            }

            case 'date':
            {
                $value = $this->_setDateValue($value);
                break;
            }

            // these types are converted to strings from another PHP type on save
            case 'serialized':
            {
                $this->_convertedValues[$field] = $value;
                $value = $this->_setSerializedValue($value);
                break;
            }
            case 'enum':
            {
                $value = $this->_setEnumValue($fieldOptions, $value);
                break;
            }
            case 'set':
            case 'list':
            {
                $value = $this->_setListValue($fieldOptions, $value);
                $this->_convertedValues[$field] = $value;
                $forceDirty = true;
                break;
            }
        }

        if ($forceDirty || (empty($this->_record[$field]) && isset($value)) || ($this->_record[$field] !== $value)) {
            $columnName = static::_cn($field);
            if (isset($this->_record[$columnName])) {
                $this->_originalValues[$field] = $this->_record[$columnName];
            }
            $this->_record[$columnName] = $value;
            $this->_isDirty = true;

            // unset invalidated relationships
            if (!empty($fieldOptions['relationships']) && static::isRelational()) {
                foreach ($fieldOptions['relationships'] as $relationship => $isCached) {
                    if ($isCached) {
                        unset($this->_relatedObjects[$relationship]);
                    }
                }
            }
            return true;
        } else {
            return false;
        }
    }
402330
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        $fieldSettings = $fieldDef->fieldTypeConstraints->fieldSettings;
        $doc = new DOMDocument('1.0', 'utf-8');
        $root = $doc->createElement('related-objects');
        $doc->appendChild($root);

        $constraints = $doc->createElement('constraints');
        if (!empty($fieldSettings['selectionContentTypes'])) {
            foreach ($fieldSettings['selectionContentTypes'] as $typeIdentifier) {
                $allowedClass = $doc->createElement('allowed-class');
                $allowedClass->setAttribute('contentclass-identifier', $typeIdentifier);
                $constraints->appendChild($allowedClass);
                unset($allowedClass);
            }
        }
        $root->appendChild($constraints);

        $selectionType = $doc->createElement('selection_type');
        $selectionMethod = isset($fieldSettings['selectionMethod']) ? (int)$fieldSettings['selectionMethod'] : 0;
        $selectionType->setAttribute('value', $selectionMethod);
        $root->appendChild($selectionType);

        $defaultLocation = $doc->createElement('contentobject-placement');
        if (!empty($fieldSettings['selectionRoot'])) {
            $defaultLocation->setAttribute('node-id', (int)$fieldSettings['selectionRoot']);
        }
        $root->appendChild($defaultLocation);

        $doc->appendChild($root);
        $storageDef->dataText5 = $doc->saveXML();

        // BC: For Backwards Compatibility for legacy and in case of downgrades or data sharing
        // Selection method, 0 = browse, 1 = dropdown
        $storageDef->dataInt1 = $selectionMethod;

        // Selection root, location ID, or 0 if empty
        $storageDef->dataInt2 = (int)$fieldSettings['selectionRoot'];
    }
289217
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
    {
        $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
            [
                'defaultAuthor' => $storageDef->dataInt1 ?? AuthorType::DEFAULT_VALUE_EMPTY,
            ]
        );

        $fieldDef->defaultValue->data = [];
    }
542204
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        $storageDef->dataText1 = $fieldDef->fieldTypeConstraints->fieldSettings['defaultValue'];
    }
859566
public function updateFieldValueValue(FieldValueInterface $fieldValue, $changeSet)
    {
        if (!isset($changeSet['value'])) {
            return;
        }

        $oldValue = unserialize($changeSet['value'][0]);
        $newValue = unserialize($changeSet['value'][1]);

        if ($newValue['src'] == '' && !$newValue['delete']) {
            $newValue['src'] = $oldValue['src'];
        }

        if ($newValue['delete']) {
            $this->uploadManager->remove($oldValue['src']);
        }

        unset($newValue['delete']);

        $fieldValue->setValue(serialize($newValue));
    }
270465
public function fillFieldWithValue(string $fieldName, $value, ?string $containerName = null): void
    {
        $newContainerName = (!$containerName) ? $containerName : sprintf($this::NEW_FIELD_TITLE_PATTERN, EzFieldElement::getFieldInternalNameByName($containerName));
        $fieldElement = $this->getField($fieldName, $newContainerName);
        $fieldElement->setValue($value);
    }
463979
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        $fieldSettings = $fieldDef->fieldTypeConstraints->fieldSettings;
        $validators = $fieldDef->fieldTypeConstraints->validators;
        $doc = new DOMDocument('1.0', 'utf-8');
        $root = $doc->createElement('related-objects');
        $doc->appendChild($root);

        $constraints = $doc->createElement('constraints');
        if (!empty($fieldSettings['selectionContentTypes'])) {
            foreach ($fieldSettings['selectionContentTypes'] as $typeIdentifier) {
                $allowedClass = $doc->createElement('allowed-class');
                $allowedClass->setAttribute('contentclass-identifier', $typeIdentifier);
                $constraints->appendChild($allowedClass);
                unset($allowedClass);
            }
        }
        $root->appendChild($constraints);

        $type = $doc->createElement('type');
        $type->setAttribute('value', 2); //Deprecated advance object relation list type, set since 4.x does
        $root->appendChild($type);

        $objectClass = $doc->createElement('object_class');
        $objectClass->setAttribute('value', ''); //Deprecated advance object relation class type, set since 4.x does
        $root->appendChild($objectClass);

        $selectionType = $doc->createElement('selection_type');
        if (isset($fieldSettings['selectionMethod'])) {
            $selectionType->setAttribute('value', (int)$fieldSettings['selectionMethod']);
        } else {
            $selectionType->setAttribute('value', 0);
        }
        $root->appendChild($selectionType);

        $defaultLocation = $doc->createElement('contentobject-placement');
        if (!empty($fieldSettings['selectionDefaultLocation'])) {
            $defaultLocation->setAttribute('node-id', (int)$fieldSettings['selectionDefaultLocation']);
        }
        $root->appendChild($defaultLocation);

        $selectionLimit = $doc->createElement('selection_limit');
        if (isset($validators['RelationListValueValidator']['selectionLimit'])) {
            $selectionLimit->setAttribute('value', (int)$validators['RelationListValueValidator']['selectionLimit']);
        } else {
            $selectionLimit->setAttribute('value', 0);
        }
        $root->appendChild($selectionLimit);

        $doc->appendChild($root);
        $storageDef->dataText5 = $doc->saveXML();
    }
124433
protected function prepareFieldValue(array &$field_value)
    {
        $this->setItemImages($field_value, 'field_value', $this->image);
        $this->setItemTranslation($field_value, 'field_value', $this->translation_entity);

        if (!empty($field_value['images'])) {
            foreach ($field_value['images'] as &$file) {
                $this->setItemTranslation($file, 'file', $this->translation_entity);
            }
        }
    }
612885
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
    {
        parent::toFieldDefinition($storageDef, $fieldDef);
        $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
            array(
                'mediaType' => $storageDef->dataText1,
            )
        );
    }