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

Date/SearchField.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\FieldType\Date;
8
9 use eZ\Publish\SPI\Persistence\Content\Field;
10 use eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition;
11 use eZ\Publish\SPI\FieldType\Indexable;
12 use eZ\Publish\SPI\Search;
13 use DateTime;
14
18 class SearchField implements Indexable
19 {
28 public function getIndexData(Field $field, FieldDefinition $fieldDefinition)
29 {
30 if ($field->value->data !== null) {
31 $dateTime = new DateTime("@{$field->value->data['timestamp']}");
32 $value = $dateTime->format('Y-m-d\\Z');
33 } else {
34 $value = null;
35 }
36
37 return [
38 new Search\Field(
39 'value',
40 $value,
41 new Search\FieldType\DateField()
42 ),
43 ];
44 }
45
51 public function getIndexDefinition()
52 {
53 return [
54 'value' => new Search\FieldType\DateField(),
55 ];
56 }
57
67 public function getDefaultMatchField()
68 {
69 return 'value';
70 }
71
81 public function getDefaultSortField()
82 {
83 return $this->getDefaultMatchField();
84 }
85 }
eZ\Publish\Core\FieldType\Date\SearchField
Indexable definition for Date field type.
Definition: Date/SearchField.php:19
eZ\Publish\Core\FieldType\Date\SearchField\getDefaultSortField
getDefaultSortField()
Get name of the default field to be used for sorting.
Definition: Date/SearchField.php:81
eZ\Publish\Core\FieldType\Date\SearchField\getIndexDefinition
getIndexDefinition()
Get index field types for search backend.
Definition: Date/SearchField.php:51
eZ\Publish\Core\FieldType\Date\SearchField\getDefaultMatchField
getDefaultMatchField()
Get name of the default field to be used for matching.
Definition: Date/SearchField.php:67
eZ\Publish\Core\FieldType\Date\SearchField\getIndexData
getIndexData(Field $field, FieldDefinition $fieldDefinition)
Get index data for field for search backend.
Definition: Date/SearchField.php:28
eZ\Publish\Core\FieldType\FieldType
Base class for field types, the most basic storage unit of data inside eZ Publish.
Definition: Core/FieldType/FieldType.php:35
eZ\Publish\SPI\Persistence\Content\Field
Definition: SPI/Persistence/Content/Field.php:12
eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition
Definition: SPI/Persistence/Content/Type/FieldDefinition.php:18
eZ\Publish\SPI\FieldType\Indexable
The field type interface which all field types have to implement to be indexable by search backends.
Definition: Indexable.php:17
eZ\Publish\Core\FieldType\Date
Definition: Date/SearchField.php:7
eZ\Publish\SPI\Search
Definition: Capable.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.