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
436571
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
    {
        $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
            array(
                'defaultType' => $storageDef->dataInt1,
            )
        );

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

        $fieldDef->defaultValue->data = $data;
    }
422507
public function getIndexData(Field $field, FieldDefinition $fieldDefinition)
    {
        return array(
            new Search\Field(
                'value',
                reset($field->value->data),
                new Search\FieldType\StringField()
            ),
        );
    }
878747
public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
    {
        $storageFieldValue->dataInt = !empty($value->data['destinationContentId'])
            ? $value->data['destinationContentId']
            : null;
        $storageFieldValue->dataText = !empty($value->data['alternativeText'])
            ? $value->data['alternativeText']
            : null;
        $storageFieldValue->sortKeyInt = (int)$value->sortKey;
    }
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();
    }
1067404
public function updateFieldDefinition(
        $typeId,
        $status,
        FieldDefinition $fieldDefinition,
        StorageFieldDefinition $storageFieldDef
    ) {
        $q = $this->dbHandler->createUpdateQuery();
        $q
            ->update(
                $this->dbHandler->quoteTable('ezcontentclass_attribute')
            )->where(
                $q->expr->eq(
                    $this->dbHandler->quoteColumn('id'),
                    $q->bindValue($fieldDefinition->id, null, \PDO::PARAM_INT)
                ),
                $q->expr->eq(
                    $this->dbHandler->quoteColumn('version'),
                    $q->bindValue($status, null, \PDO::PARAM_INT)
                ),
                // @todo FIXME: Actually not needed
                $q->expr->eq(
                    $this->dbHandler->quoteColumn('contentclass_id'),
                    $q->bindValue($typeId, null, \PDO::PARAM_INT)
                )
            );
        $this->setCommonFieldColumns($q, $fieldDefinition, $storageFieldDef);

        $q->prepare()->execute();

        foreach ($storageFieldDef->multilingualData as $languageCode => $data) {
            $dataExist = $this->fieldDefinitionMultilingualDataExist(
                $fieldDefinition,
                $data->languageId,
                $status
            );

            if ($dataExist) {
                $this->updateFieldDefinitionMultilingualData(
                    $fieldDefinition->id,
                    $data,
                    $status
                );
            } else {
                //When creating new translation there are no fields for update.
                $this->insertFieldDefinitionMultilingualData(
                    $fieldDefinition->id,
                    $data,
                    $status
                );
            }
        }
    }
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 ?: '';
    }
804648
protected function generateFieldSql( $fieldName, ezcDbSchemaField $fieldDefinition )
    {
        $sqlDefinition = "'$fieldName' ";
        $defList = array();

        $type = $this->convertFromGenericType( $fieldDefinition );
        $defList[] = $type;

        if ( $fieldDefinition->notNull )
        {
            $defList[] = 'NOT NULL';
        }

        if ( $fieldDefinition->autoIncrement )
        {
            $defList[] = "PRIMARY KEY AUTOINCREMENT";
            $this->context['skip_primary'] = true;
        }
        
        if ( !is_null( $fieldDefinition->default ) && !$fieldDefinition->autoIncrement )
        {
            $default = $this->generateDefault( $fieldDefinition->type, $fieldDefinition->default );
            $defList[] = "DEFAULT $default";
        }

        $sqlDefinition .= join( ' ', $defList );

        return $sqlDefinition;
    }
268897
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
    {
        $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
            array(
                'isMultiple' => !empty($storageDef->dataInt1) ? (bool)$storageDef->dataInt1 : false,
            )
        );

        $fieldDef->defaultValue->data = empty($storageDef->dataText5)
            ? null
            : explode(',', $storageDef->dataText5);
        // TODO This will contain comma separated country codes, which is correct for value but not for sort key.
        // Sort key should contain comma separated lowercased country names.
        $fieldDef->defaultValue->sortKey = $storageDef->dataText5;
    }
260174
private function setBaseValues(ApiDefinition $apiDef)
    {
        $this->registerHost($apiDef);
        $basePath = $this->document->getBasePath();
        if (isset($basePath)) {
            $apiDef->setBasePath($basePath);
        }
    }
850593
public function usePersistence(PersistenceDefinition $definition, StorageType $storageType = null)
    {
        $enabledPersistences = $this->settings->tryGet(KnownSettingsEnum::ENABLED_PERSISTENCES) ?: [];

        $enabledPersistences[] = new EnabledPersistence($definition, $storageType);

        $this->settings->set(KnownSettingsEnum::ENABLED_PERSISTENCES, $enabledPersistences);

        return $definition->createConfigurator($this->settings);
    }
921428
public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
    {
        $fieldValue->data = array('destinationContentIds' => array());
        if ($value->dataText === null) {
            return;
        }

        $priorityByContentId = array();

        $dom = new DOMDocument('1.0', 'utf-8');
        if ($dom->loadXML($value->dataText) === true) {
            foreach ($dom->getElementsByTagName('relation-item') as $relationItem) {
                /* @var \DOMElement $relationItem */
                $priorityByContentId[$relationItem->getAttribute('contentobject-id')] =
                    $relationItem->getAttribute('priority');
            }
        }

        asort($priorityByContentId, SORT_NUMERIC);

        $fieldValue->data['destinationContentIds'] = array_keys($priorityByContentId);
        $fieldValue->sortKey = $value->sortKeyString;
    }
876880
protected function generateAddFieldSql( $tableName, $fieldName, ezcDbSchemaField $fieldDefinition )
    {
        $this->queries[] = "ALTER TABLE \"$tableName\" ADD " . $this->generateFieldSql( $fieldName, $fieldDefinition );
    }
1191986
private function createFieldDefinition(FieldDefinitionObject $field)
    {
        $definition = $this->contentTypeService->newFieldDefinitionCreateStruct($field->data['identifier'], $field->data['type']);
        $field->getMapper()->mapObjectToCreateStruct($definition);

        return $definition;
    }
307176
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        if (isset($fieldDef->fieldTypeConstraints->validators[self::FLOAT_VALIDATOR_IDENTIFIER]['minIntegerValue'])) {
            $storageDef->dataInt1 = $fieldDef->fieldTypeConstraints->validators[self::FLOAT_VALIDATOR_IDENTIFIER]['minIntegerValue'];
        }
        if (isset($fieldDef->fieldTypeConstraints->validators[self::FLOAT_VALIDATOR_IDENTIFIER]['maxIntegerValue'])) {
            $storageDef->dataInt2 = $fieldDef->fieldTypeConstraints->validators[self::FLOAT_VALIDATOR_IDENTIFIER]['maxIntegerValue'];
        }

        if ($storageDef->dataInt1 === false || $storageDef->dataInt2 === false) {
            @trigger_error(
                "The IntegerValueValidator constraint value 'false' is deprecated, and will be removed in 7.0. Use 'null' instead.",
                E_USER_DEPRECATED
            );
            $storageDef->dataInt1 = $storageDef->dataInt1 === false ? null : $storageDef->dataInt1;
            $storageDef->dataInt2 = $storageDef->dataInt2 === false ? null : $storageDef->dataInt2;
        }

        // Defining dataInt4 which holds the validator state (min value/max value/minMax value)
        $storageDef->dataInt4 = $this->getStorageDefValidatorState($storageDef->dataInt1, $storageDef->dataInt2);
        $storageDef->dataInt3 = $fieldDef->defaultValue->data;
    }
475396
public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
    {
        $fieldValue->data = $value->dataText === null
            ? null
            : $this->restoreValueFromXmlString($value->dataText);
    }
904265
public function toFieldDefinition( StorageFieldDefinition $storageDef, FieldDefinition $fieldDef )
    {
        $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
            array(
                "configuration" => json_decode( $storageDef->dataText5, true )
            )
        );
    }
726790
public function getFieldLayout(array $fieldLayoutDef): FieldLayout
    {
        $layoutFields = [];
        $requiredFields = [];

        if (array_key_exists('tabs', $fieldLayoutDef)) {
            foreach ($fieldLayoutDef['tabs'] as $tabName => $tabDef) {
                $layoutTabFields = $this->getPrepareFieldLayout($tabDef);
                $requiredFields = array_merge($requiredFields, $layoutTabFields['required']);
                $layoutFields[$tabName] = $layoutTabFields['fields'];
            }
        } elseif (array_key_exists('fields', $fieldLayoutDef)) {
            $layoutTabFields = $this->getPrepareFieldLayout($fieldLayoutDef);
            $requiredFields = $layoutTabFields['required'];
            $layoutFields = $layoutTabFields['fields'];
        }

        $fieldLayout = Craft::$app->fields->assembleLayout($layoutFields, $requiredFields);

        if (array_key_exists('type', $fieldLayoutDef)) {
            $fieldLayout->type = $fieldLayoutDef['type'];
        } else {
            $fieldLayout->type = Entry::class;
        }

        return $fieldLayout;
    }