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
542204
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        $storageDef->dataText1 = $fieldDef->fieldTypeConstraints->fieldSettings['defaultValue'];
    }
213677
public function getIndexData(Field $field, FieldDefinition $fieldDefinition)
    {
        return array(
            new Search\Field(
                'value',
                $field->value->data,
                new Search\FieldType\FloatField()
            ),
            new Search\Field(
                'fulltext',
                $field->value->data,
                new Search\FieldType\FullTextField()
            ),
        );
    }
1191986
private function createFieldDefinition(FieldDefinitionObject $field)
    {
        $definition = $this->contentTypeService->newFieldDefinitionCreateStruct($field->data['identifier'], $field->data['type']);
        $field->getMapper()->mapObjectToCreateStruct($definition);

        return $definition;
    }
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;
    }
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()
            ),
        );
    }
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,
        ];
    }
876880
protected function generateAddFieldSql( $tableName, $fieldName, ezcDbSchemaField $fieldDefinition )
    {
        $this->queries[] = "ALTER TABLE \"$tableName\" ADD " . $this->generateFieldSql( $fieldName, $fieldDefinition );
    }
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();
    }
904265
public function toFieldDefinition( StorageFieldDefinition $storageDef, FieldDefinition $fieldDef )
    {
        $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
            array(
                "configuration" => json_decode( $storageDef->dataText5, true )
            )
        );
    }
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;
    }
42363
public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
    {
        if (isset($fieldDef->fieldTypeConstraints->validators[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['maxStringLength'])) {
            $storageDef->dataInt1 = $fieldDef->fieldTypeConstraints->validators[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['maxStringLength'];
        } else {
            $storageDef->dataInt1 = 0;
        }

        if (isset($fieldDef->fieldTypeConstraints->validators[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['minStringLength'])) {
            $storageDef->dataInt2 = $fieldDef->fieldTypeConstraints->validators[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['minStringLength'];
        } else {
            $storageDef->dataInt2 = 0;
        }

        $storageDef->dataText1 = $fieldDef->defaultValue->data;
    }
695796
public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
    {
        $fieldValue->data = array(
            'urlId' => $value->dataInt,
            'text' => $value->dataText,
        );
        $fieldValue->sortKey = false;
    }
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;
    }
360668
public function addStoredFields($storedFields)
    {
        if (!isset($this->_fdxFile)) {
            $this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx');
            $this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt');

            $this->_files[] = $this->_name . '.fdx';
            $this->_files[] = $this->_name . '.fdt';
        }

        $this->_fdxFile->writeLong($this->_fdtFile->tell());
        $this->_fdtFile->writeVInt(count($storedFields));
        foreach ($storedFields as $field) {
            $this->_fdtFile->writeVInt($this->_fields[$field->name]->number);
            $fieldBits = ($field->isTokenized ? 0x01 : 0x00) |
                         ($field->isBinary ?    0x02 : 0x00) |
                         0x00; /* 0x04 - third bit, compressed (ZLIB) */
            $this->_fdtFile->writeByte($fieldBits);
            if ($field->isBinary) {
                $this->_fdtFile->writeVInt(strlen($field->value));
                $this->_fdtFile->writeBytes($field->value);
            } else {
                $this->_fdtFile->writeString($field->getUtf8Value());
            }
        }

        $this->_docCount++;
    }
253693
protected function updateField(Field $field, Content $content)
    {
        $this->contentGateway->updateField(
            $field,
            $this->mapper->convertToStorageValue($field)
        );

        // If the storage handler returns true, it means that $field value has been modified
        // So we need to update it in order to store those modifications
        // Field converter is called once again via the Mapper
        if ($this->storageHandler->storeFieldData($content->versionInfo, $field) === true) {
            $this->contentGateway->updateField(
                $field,
                $this->mapper->convertToStorageValue($field)
            );
        }
    }
48611
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
    {
        // @todo: Is it possible to store a default value in the DB?
        $fieldDef->defaultValue = new FieldValue();
        $fieldDef->defaultValue->data = array('text' => null);
    }
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 );
    }