1 | <?php |
||
17 | class RelationConverter implements Converter |
||
18 | { |
||
19 | /** |
||
20 | * Factory for current class. |
||
21 | * |
||
22 | * Note: Class should instead be configured as service if it gains dependencies. |
||
23 | * |
||
24 | * @return Url |
||
25 | */ |
||
26 | public static function create() |
||
30 | |||
31 | /** |
||
32 | * Converts data from $value to $storageFieldValue. |
||
33 | * |
||
34 | * @param \eZ\Publish\SPI\Persistence\Content\FieldValue $value |
||
35 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $storageFieldValue |
||
36 | */ |
||
37 | public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue) |
||
38 | { |
||
39 | $storageFieldValue->dataInt = !empty($value->data['destinationContentId']) |
||
40 | ? $value->data['destinationContentId'] |
||
41 | : null; |
||
42 | $storageFieldValue->sortKeyInt = (int)$value->sortKey; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Converts data from $value to $fieldValue. |
||
47 | * |
||
48 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value |
||
49 | * @param \eZ\Publish\SPI\Persistence\Content\FieldValue $fieldValue |
||
50 | */ |
||
51 | public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue) |
||
52 | { |
||
53 | $fieldValue->data = array( |
||
54 | 'destinationContentId' => $value->dataInt ?: null, |
||
55 | ); |
||
56 | $fieldValue->sortKey = (int)$value->sortKeyInt; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Converts field definition data in $fieldDef into $storageFieldDef. |
||
61 | * |
||
62 | * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef |
||
63 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef |
||
64 | */ |
||
65 | public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef) |
||
73 | |||
74 | /** |
||
75 | * Converts field definition data in $storageDef into $fieldDef. |
||
76 | * |
||
77 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef |
||
78 | * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef |
||
79 | */ |
||
80 | public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef) |
||
92 | |||
93 | /** |
||
94 | * Returns the name of the index column in the attribute table. |
||
95 | * |
||
96 | * Returns the name of the index column the datatype uses, which is either |
||
97 | * "sort_key_int" or "sort_key_string". This column is then used for |
||
98 | * filtering and sorting for this type. |
||
99 | * |
||
100 | * @return false |
||
101 | */ |
||
102 | public function getIndexColumn() |
||
106 | } |
||
107 |