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

ISBNConverter.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 use eZ\Publish\Core\FieldType\FieldSettings;
15
16 class ISBNConverter implements Converter
17 {
27 public static function create()
28 {
29 return new self();
30 }
31
38 public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
39 {
40 $storageFieldValue->dataText = $value->data;
41 $storageFieldValue->sortKeyString = $value->sortKey;
42 }
43
50 public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
51 {
52 $fieldValue->data = $value->dataText;
53 $fieldValue->sortKey = $value->sortKeyString;
54 }
55
62 public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
63 {
64 if (isset($fieldDef->fieldTypeConstraints->fieldSettings['isISBN13'])) {
65 $storageDef->dataInt1 = $fieldDef->fieldTypeConstraints->fieldSettings['isISBN13'];
66 } else {
67 $storageDef->dataInt1 = 1;
68 }
69
70 $storageDef->dataText1 = $fieldDef->defaultValue->data;
71 }
72
79 public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
80 {
81 $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
82 [
83 'isISBN13' => !empty($storageDef->dataInt1) ? (bool)$storageDef->dataInt1 : false,
84 ]
85 );
86
87 $fieldDef->defaultValue->data = $storageDef->dataText1 ?: null;
88 $fieldDef->defaultValue->sortKey = $storageDef->dataText1 ?: '';
89 }
90
100 public function getIndexColumn()
101 {
102 return 'sort_key_string';
103 }
104 }
eZ\Publish\Core\FieldType\FieldSettings
Container for field type specific properties.
Definition: FieldSettings.php:19
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter
Definition: ISBNConverter.php:17
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter\getIndexColumn
getIndexColumn()
Returns the name of the index column in the attribute table.
Definition: ISBNConverter.php:100
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter\toFieldDefinition
toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
Converts field definition data in $storageDef into $fieldDef.
Definition: ISBNConverter.php:79
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter\toFieldValue
toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
Converts data from $value to $fieldValue.
Definition: ISBNConverter.php:50
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter\create
static create()
Factory for current class.
Definition: ISBNConverter.php:27
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter\toStorageFieldDefinition
toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
Converts field definition data in $fieldDef into $storageFieldDef.
Definition: ISBNConverter.php:62
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter\toStorageValue
toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
Converts data from $value to $storageFieldValue.
Definition: ISBNConverter.php:38
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+.