public toStorageFieldDefinition ( eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef, |
||
$fieldDef | eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition | |
$storageDef |
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;
}
/** * @group fieldType * @group textLine * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLineConverter::toStorageFieldDefinition */ public function testToStorageFieldDefinitionNoValidator() { $defaultText = 'This is a default text'; $storageFieldDef = new StorageFieldDefinition(); $defaultValue = new FieldValue(); $defaultValue->data = $defaultText; $fieldTypeConstraints = new FieldTypeConstraints(); $fieldDef = new PersistenceFieldDefinition(array('fieldTypeConstraints' => $fieldTypeConstraints, 'defaultValue' => $defaultValue)); $this->converter->toStorageFieldDefinition($fieldDef, $storageFieldDef); self::assertSame(0, $storageFieldDef->dataInt1); self::assertSame($fieldDef->defaultValue->data, $storageFieldDef->dataText1); }