Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

TextLineConverter.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter;
8
9 use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter;
10 use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue;
11 use eZ\Publish\SPI\Persistence\Content\FieldValue;
12 use eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition;
13 use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition;
14
15 class TextLineConverter implements Converter
16 {
17 const STRING_LENGTH_VALIDATOR_IDENTIFIER = 'StringLengthValidator';
18
28 public static function create()
29 {
30 return new self();
31 }
32
39 public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
40 {
41 $storageFieldValue->dataText = $value->data;
42 $storageFieldValue->sortKeyString = $value->sortKey;
43 }
44
51 public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
52 {
53 $fieldValue->data = $value->dataText;
54 $fieldValue->sortKey = $value->sortKeyString;
55 }
56
63 public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
64 {
65 if (isset($fieldDef->fieldTypeConstraints->validators[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['maxStringLength'])) {
66 $storageDef->dataInt1 = $fieldDef->fieldTypeConstraints->validators[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['maxStringLength'];
67 } else {
68 $storageDef->dataInt1 = 0;
69 }
70
71 if (isset($fieldDef->fieldTypeConstraints->validators[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['minStringLength'])) {
72 $storageDef->dataInt2 = $fieldDef->fieldTypeConstraints->validators[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['minStringLength'];
73 } else {
74 $storageDef->dataInt2 = 0;
75 }
76
77 $storageDef->dataText1 = $fieldDef->defaultValue->data;
78 }
79
86 public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
87 {
88 $validatorConstraints = [];
89
90 if (isset($storageDef->dataInt1)) {
91 $validatorConstraints[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['maxStringLength'] =
92 $storageDef->dataInt1 != 0 ?
93 (int)$storageDef->dataInt1 :
94 null;
95 }
96 if (isset($storageDef->dataInt2)) {
97 $validatorConstraints[self::STRING_LENGTH_VALIDATOR_IDENTIFIER]['minStringLength'] =
98 $storageDef->dataInt2 != 0 ?
99 (int)$storageDef->dataInt2 :
100 null;
101 }
102
103 $fieldDef->fieldTypeConstraints->validators = $validatorConstraints;
104 $fieldDef->defaultValue->data = $storageDef->dataText1 ?: null;
105 $fieldDef->defaultValue->sortKey = $storageDef->dataText1 ?: '';
106 }
107
117 public function getIndexColumn()
118 {
119 return 'sort_key_string';
120 }
121 }
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLineConverter
Definition: TextLineConverter.php:16
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLineConverter\toStorageFieldDefinition
toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
Converts field definition data in $fieldDef into $storageFieldDef.
Definition: TextLineConverter.php:63
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLineConverter\STRING_LENGTH_VALIDATOR_IDENTIFIER
const STRING_LENGTH_VALIDATOR_IDENTIFIER
Definition: TextLineConverter.php:17
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLineConverter\toStorageValue
toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
Converts data from $value to $storageFieldValue.
Definition: TextLineConverter.php:39
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLineConverter\getIndexColumn
getIndexColumn()
Returns the name of the index column in the attribute table.
Definition: TextLineConverter.php:117
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLineConverter\create
static create()
Factory for current class.
Definition: TextLineConverter.php:28
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLineConverter\toFieldValue
toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
Converts data from $value to $fieldValue.
Definition: TextLineConverter.php:51
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLineConverter\toFieldDefinition
toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
Converts field definition data in $storageDef into $fieldDef.
Definition: TextLineConverter.php:86
eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition
Definition: StorageFieldDefinition.php:12
eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue
Definition: StorageFieldValue.php:12
eZ\Publish\SPI\Persistence\Content\FieldValue
Definition: FieldValue.php:12
eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition
Definition: SPI/Persistence/Content/Type/FieldDefinition.php:18
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter
Converter for field values in legacy storage.
Definition: Persistence/Legacy/Content/FieldValue/Converter.php:18
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter
Definition: AuthorConverter.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.