Converts field definition data in $storageDef into $fieldDef.

@param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef
@param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef
16000
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
    {
        $useSeconds = (bool)$storageDef->dataInt2;
        $dateInterval = $this->getDateIntervalFromXML($storageDef->dataText5);

        $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
            array(
                'defaultType' => $storageDef->dataInt1,
                'useSeconds' => $useSeconds,
                'dateInterval' => $dateInterval,
            )
        );

        // Building default value
        switch ($fieldDef->fieldTypeConstraints->fieldSettings['defaultType']) {
            case DateAndTimeType::DEFAULT_CURRENT_DATE:
                $data = array(
                    'rfc850' => null,
                    'timestamp' => time(), // @deprecated timestamp is no longer used and will be removed in a future version.
                    'timestring' => 'now',
                );
                break;

            case DateAndTimeType::DEFAULT_CURRENT_DATE_ADJUSTED:
                if (!$useSeconds) {
                    $dateInterval->s = 0;
                }
                $date = new DateTime();
                $date->add($dateInterval);
                $data = array(
                    'rfc850' => null,
                    'timestamp' => $date->getTimestamp(), // @deprecated timestamp is no longer used and will be removed in a future version.
                    'timestring' => $dateInterval->format('%y years, %m months, %d days, %h hours, %i minutes, %s seconds'),
                );
                break;

            default:
                $data = null;
        }

        $fieldDef->defaultValue->data = $data;
    }
1315503
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
    {
        $validatorConstraints = array(self::VALIDATOR_IDENTIFIER => array());
        $fieldDef->fieldTypeConstraints->validators = $validatorConstraints;
        $fieldDef->defaultValue->data = isset($storageDef->dataText1) ? $storageDef->dataText1 : '';
        $fieldDef->defaultValue->sortKey = $fieldDef->defaultValue->data;
    }
884747
protected function translateFieldCode(FieldsDefinition $fields, $fieldId)
    {
        $field = $fields->getField($fieldId);
        if ($field instanceof FieldInterface) {
            return  '{f' . $field->getOrder() . '}';
        }

        return $fieldId;
    }
532773
public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
    {
        $storageFieldValue->dataInt = !empty($value->data['destinationContentId'])
            ? $value->data['destinationContentId']
            : null;
        $storageFieldValue->sortKeyInt = (int)$value->sortKey;
    }
946504
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        $fieldSettings = $fieldDef->fieldTypeConstraints->fieldSettings;

        if (isset($fieldSettings['isMultiple'])) {
            $storageDef->dataInt1 = (int)$fieldSettings['isMultiple'];
        }

        if (!empty($fieldSettings['options'])) {
            $xml = $this->buildOptionsXml($fieldSettings['options']);
            $storageDef->dataText5 = $xml->saveXML();
        }

        if (!isset($fieldSettings['multilingualOptions'])) {
            return;
        }

        foreach ($fieldSettings['multilingualOptions'] as $languageCode => $option) {
            $xml = $this->buildOptionsXml($option);

            $storageDef->multilingualData[$languageCode]->dataText = $xml->saveXML();

            if ($fieldDef->mainLanguageCode === $languageCode) {
                $storageDef->dataText5 = $xml->saveXML();
            }
        }
    }
695796
public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
    {
        $fieldValue->data = array(
            'urlId' => $value->dataInt,
            'text' => $value->dataText,
        );
        $fieldValue->sortKey = false;
    }
332527
public function setFieldDefinitions(array $fieldDefinitionObjects)
    {
        $this->data['fields'] = [];
        foreach ($fieldDefinitionObjects as $identifier => $fieldDefinitionObject) {
            $this->addFieldDefinitionObject($identifier, $fieldDefinitionObject);
        }
    }
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;
    }
1214615
public function getFieldDefsByType($fieldDef)
    {
        if (is_string($fieldDef)) {
            $fieldDef = array('type' => $fieldDef);
        }

        if (isset($fieldDef['type'])) {
            return $this->getMetadata()->get('fields.'.$fieldDef['type']);
        }

        return null;
    }
700257
public function onPreDelete(StorageEvent $event)
    {
        $entity = $event->getContent();
        if (!$entity instanceof Entity\Content) {
            return;
        }
        $taxonomies = $entity->getTaxonomy();
        if ($taxonomies instanceof Collection\Taxonomy) {
            $repo = $this->em->getRepository(Entity\Taxonomy::class);
            foreach ($taxonomies as $taxonomy) {
                $repo->delete($taxonomy);
            }
        }
        $relations = $entity->getRelation();
        if ($relations instanceof Collection\Relations) {
            $repo = $this->em->getRepository(Entity\Relations::class);
            foreach ($relations as $relation) {
                $repo->delete($relation);
            }
        }
    }
1029205
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        if (isset($fieldDef->fieldTypeConstraints->validators[self::FLOAT_VALIDATOR_IDENTIFIER]['minFloatValue'])) {
            $storageDef->dataFloat1 = $fieldDef->fieldTypeConstraints->validators[self::FLOAT_VALIDATOR_IDENTIFIER]['minFloatValue'];
        }

        if (isset($fieldDef->fieldTypeConstraints->validators[self::FLOAT_VALIDATOR_IDENTIFIER]['maxFloatValue'])) {
            $storageDef->dataFloat2 = $fieldDef->fieldTypeConstraints->validators[self::FLOAT_VALIDATOR_IDENTIFIER]['maxFloatValue'];
        }

        // Defining dataFloat4 which holds the validator state (min value/max value)
        $storageDef->dataFloat4 = $this->getStorageDefValidatorState($storageDef->dataFloat1, $storageDef->dataFloat2);
        $storageDef->dataFloat3 = $fieldDef->defaultValue->data;
    }
184080
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        $storageDef->dataInt3 = (int)$fieldDef->defaultValue->data;
    }
1308595
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
    {
        $validatorConstraints = array();

        if (isset($storageDef->dataInt1)) {
            $validatorConstraints[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['maxStringLength'] =
                $storageDef->dataInt1 != 0 ?
                    (int)$storageDef->dataInt1 :
                    null;
        }
        if (isset($storageDef->dataInt2)) {
            $validatorConstraints[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['minStringLength'] =
                $storageDef->dataInt2 != 0 ?
                    (int)$storageDef->dataInt2 :
                    null;
        }

        $fieldDef->fieldTypeConstraints->validators = $validatorConstraints;
        $fieldDef->defaultValue->data = $storageDef->dataText1 ?: null;
        $fieldDef->defaultValue->sortKey = $storageDef->dataText1 ?: '';
    }
1015064
public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
    {
        $fieldValue->data = $this->restoreValueFromXmlString($value->dataText);
        $fieldValue->sortKey = $value->sortKeyString;
    }
723595
public function addField(FieldDefinition $field): FieldsAwareDefinitionInterface
    {
        $this->fields[$field->getName()] = $field;

        return $this;
    }
917373
public function setFieldDec($fieldName, float $decValue = 1)
    {
        $this->option->saveData[$fieldName] = new Raw(new Field($fieldName) . ' - ' . $decValue);
        return $this;
    }
1089398
protected function appendFieldDefinition(NodeBuilder $fieldDefinition): void
    {
        $fieldDefinition
            ->scalarNode('type')->defaultValue('text')->end()
            ->scalarNode('label')->defaultNull()->end()
            ->scalarNode('form_type')->defaultNull()->end()
            ->arrayNode('attributes')
                ->prototype('scalar')->defaultNull()->end()
            ->end()
            ->variableNode('default')->defaultNull()->end()
            ->variableNode('options')
                ->defaultValue([])
                ->validate()
                ->ifTrue(function ($value) {
                    return !\is_array($value) && null !== $value;
                })
                ->thenInvalid('"options" configuration must be an array or left empty')
                ->end()
            ->end()
            ->variableNode('form_options')
                ->defaultValue([])
                ->validate()
                ->ifTrue(function ($value) {
                    return !\is_array($value) && null !== $value;
                })
                ->thenInvalid('"form_options" configuration must be an array or left empty')
                ->end()
            ->end();
    }