@@ 13-43 (lines=31) @@ | ||
10 | use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface; |
|
11 | use Netgen\InformationCollection\API\Value\Legacy\FieldValue; |
|
12 | ||
13 | class DateAndTimeFieldHandler implements CustomLegacyFieldHandlerInterface |
|
14 | { |
|
15 | /** |
|
16 | * {@inheritdoc} |
|
17 | */ |
|
18 | public function supports(Value $value): bool |
|
19 | { |
|
20 | return $value instanceof DateAndTimeValue; |
|
21 | } |
|
22 | ||
23 | /** |
|
24 | * {@inheritdoc} |
|
25 | */ |
|
26 | public function toString(Value $value, FieldDefinition $fieldDefinition): string |
|
27 | { |
|
28 | if ($value instanceof DateAndTimeValue) { |
|
29 | return (string) $value; |
|
30 | } |
|
31 | ||
32 | } |
|
33 | ||
34 | /** |
|
35 | * @param \eZ\Publish\Core\FieldType\DateAndTime\Value $value |
|
36 | * |
|
37 | * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue |
|
38 | */ |
|
39 | public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue |
|
40 | { |
|
41 | return FieldValue::withIntValue($fieldDefinition->id, $value->value->getTimestamp()); |
|
42 | } |
|
43 | } |
|
44 |
@@ 13-40 (lines=28) @@ | ||
10 | use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface; |
|
11 | use Netgen\InformationCollection\API\Value\Legacy\FieldValue; |
|
12 | ||
13 | class FloatFieldHandler implements CustomLegacyFieldHandlerInterface |
|
14 | { |
|
15 | /** |
|
16 | * {@inheritdoc} |
|
17 | */ |
|
18 | public function supports(Value $value): bool |
|
19 | { |
|
20 | return $value instanceof FloatValue; |
|
21 | } |
|
22 | ||
23 | /** |
|
24 | * {@inheritdoc} |
|
25 | */ |
|
26 | public function toString(Value $value, FieldDefinition $fieldDefinition): string |
|
27 | { |
|
28 | return (string) $value; |
|
29 | } |
|
30 | ||
31 | /** |
|
32 | * @param \eZ\Publish\Core\FieldType\Float\Value $value |
|
33 | * |
|
34 | * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue |
|
35 | */ |
|
36 | public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue |
|
37 | { |
|
38 | return FieldValue::withFloatValue($fieldDefinition->id, $value->value); |
|
39 | } |
|
40 | } |
|
41 |
@@ 13-40 (lines=28) @@ | ||
10 | use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface; |
|
11 | use Netgen\InformationCollection\API\Value\Legacy\FieldValue; |
|
12 | ||
13 | class IntegerFieldHandler implements CustomLegacyFieldHandlerInterface |
|
14 | { |
|
15 | /** |
|
16 | * {@inheritdoc} |
|
17 | */ |
|
18 | public function supports(Value $value): bool |
|
19 | { |
|
20 | return $value instanceof IntegerValue; |
|
21 | } |
|
22 | ||
23 | /** |
|
24 | * {@inheritdoc} |
|
25 | */ |
|
26 | public function toString(Value $value, FieldDefinition $fieldDefinition): string |
|
27 | { |
|
28 | return (string) $value; |
|
29 | } |
|
30 | ||
31 | /** |
|
32 | * @param \eZ\Publish\Core\FieldType\Integer\Value $value |
|
33 | * |
|
34 | * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue |
|
35 | */ |
|
36 | public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue |
|
37 | { |
|
38 | return FieldValue::withIntValue($fieldDefinition->id, $value->value); |
|
39 | } |
|
40 | } |
|
41 |