Converts field definition data in $fieldDef into $storageFieldDef.

@param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef
@param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef
184080
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        $storageDef->dataInt3 = (int)$fieldDef->defaultValue->data;
    }
1188481
protected static function replaceFieldsWithLongNames( eZDBInterface $db, array $fieldDefs, &$fields )
    {
        if ( !$db->useShortNames() || !$fields )
            return;

        foreach ( $fieldDefs as $fieldName => $fieldDefinition )
        {
            if ( !isset( $fieldDefinition['short_name'] ) )
            {
                continue;
            }
            $shortName = $fieldDefinition['short_name'];
            if ( !isset( $fields[$shortName] ) )
            {
                continue;
            }
            $fields[$fieldName] = $fields[$shortName];
            unset( $fields[$shortName] );
        }
    }
1054105
public function getIndexData(Field $field, FieldDefinition $fieldDefinition)
    {
        return array(
            new Search\Field(
                'filename',
                $field->value->data['fileName'],
                new Search\FieldType\StringField()
            ),
            new Search\Field(
                'alternative_text',
                $field->value->data['alternativeText'],
                new Search\FieldType\StringField()
            ),
            new Search\Field(
                'file_size',
                $field->value->data['fileSize'],
                new Search\FieldType\IntegerField()
            ),
            new Search\Field(
                'mime_type',
                $field->value->data['mime'],
                new Search\FieldType\StringField()
            ),
        );
    }
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);
    }
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'];
    }
507137
public void addFieldDefinition(FieldDefinition fieldDef) {
        // Assure field name is unique and add the definition to the map.
        Utils.require(!Utils.isEmpty(fieldDef.getName()), "Field name is required");
        Utils.require(!m_fieldDefMap.containsKey(fieldDef.getName()),
                      "Field names must be unique: " + fieldDef.getName());
        m_fieldDefMap.put(fieldDef.getName(), fieldDef);
        fieldDef.setTableDefinition(this);

        // Recurse to nested fields, if any.
        if (fieldDef.isGroupField()) {
            for (FieldDefinition nestedFieldDef : fieldDef.getNestedFields()) {
                addFieldDefinition(nestedFieldDef);
            }
        }
    }
1369025
public function toFieldDefinition(StorageFieldDefinition $storageDefinition, FieldDefinition $fieldDefinition)
    {
        $fieldDefinition->defaultValue->data = Value::EMPTY_VALUE;
    }
580067
public function toStorageFieldDefinition(
        FieldDefinition $fieldDef,
        StorageFieldDefinition $storageFieldDef
    ) {
        foreach (array_keys($fieldDef->name) as $languageCode) {
            $multilingualData = new MultilingualStorageFieldDefinition();
            $multilingualData->name = $fieldDef->name[$languageCode];
            $multilingualData->description = $fieldDef->description[$languageCode] ?? null;
            $multilingualData->languageId =
                $this->maskGenerator->generateLanguageMaskFromLanguageCodes([$languageCode]);

            $storageFieldDef->multilingualData[$languageCode] = $multilingualData;
        }

        $converter = $this->converterRegistry->getConverter(
            $fieldDef->fieldType
        );

        $converter->toStorageFieldDefinition(
            $fieldDef,
            $storageFieldDef
        );
    }
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
        }
    }
465640
private function getPrepareFieldLayout(array $fieldLayoutDef): array
    {
        $layoutFields = [];
        $requiredFields = [];

        foreach ($fieldLayoutDef as $fieldHandle => $required) {
            $field = Craft::$app->fields->getFieldByHandle($fieldHandle);
            if ($field instanceof Field) {
                $layoutFields[] = $field->id;

                if ($required) {
                    $requiredFields[] = $field->id;
                }
            }
        }

        return [
          'fields' => $layoutFields,
          'required' => $requiredFields,
        ];
    }
633389
protected function generateAddFieldSql( $tableName, $fieldName, ezcDbSchemaField $fieldDefinition )
    {
        if ( $fieldDefinition->notNull && $fieldDefinition->default == null ) 
        {
            $fieldDefinition->default = $this->generateDefault( $fieldDefinition->type, 0 );

        }
        $this->queries[] = "ALTER TABLE '$tableName' ADD " . $this->generateFieldSql( $fieldName, $fieldDefinition );
    }
143217
public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
    {
        $storageFieldValue->dataInt = isset($value->externalData['address']) ? 1 : 0;
        $storageFieldValue->dataText = '';
        $storageFieldValue->sortKeyString = (string)$value->sortKey;
    }
723595
public function addField(FieldDefinition $field): FieldsAwareDefinitionInterface
    {
        $this->fields[$field->getName()] = $field;

        return $this;
    }
922692
public function insertExistingField(Content $content, Field $field, StorageFieldValue $value)
    {
        $q = $this->dbHandler->createInsertQuery();

        $this->setInsertFieldValues($q, $content, $field, $value);

        $q->set(
            $this->dbHandler->quoteColumn('id'),
            $q->bindValue($field->id, null, \PDO::PARAM_INT)
        );

        $q->prepare()->execute();
    }
802620
public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
    {
        $storageFieldValue->sortKeyString = $storageFieldValue->dataText = $value->sortKey;
    }
874083
protected function generateChangeFieldSql( $tableName, $fieldName, ezcDbSchemaField $fieldDefinition )
    {
        $this->queries[] = "ALTER TABLE '$tableName' CHANGE '$fieldName' " . $this->generateFieldSql( $fieldName, $fieldDefinition );
    }
464268
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        $storageDef->dataInt2 = $fieldDef->fieldTypeConstraints->fieldSettings['useSeconds'] ? 1 : 0;
        $storageDef->dataInt1 = $fieldDef->fieldTypeConstraints->fieldSettings['defaultType'];

        if ($fieldDef->fieldTypeConstraints->fieldSettings['defaultType'] === DateAndTimeType::DEFAULT_CURRENT_DATE_ADJUSTED) {
            $storageDef->dataText5 = $this->generateDateIntervalXML(
                $fieldDef->fieldTypeConstraints->fieldSettings['dateInterval']
            );
        }
    }