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

Author/SearchField.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\FieldType\Author;
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
17 class SearchField implements Indexable
18 {
27 public function getIndexData(Field $field, FieldDefinition $fieldDefinition)
28 {
29 $name = [];
30 $id = [];
31 $email = [];
32
33 foreach ($field->value->data as $author) {
34 $name[] = $author['name'];
35 $id[] = $author['id'];
36 $email[] = $author['email'];
37 }
38
39 return [
40 new Search\Field(
41 'name',
42 $name,
43 new Search\FieldType\MultipleStringField()
44 ),
45 new Search\Field(
46 'id',
47 $id,
48 new Search\FieldType\MultipleIntegerField()
49 ),
50 new Search\Field(
51 'email',
52 $email,
53 new Search\FieldType\MultipleStringField()
54 ),
55 new Search\Field(
56 'count',
57 count($field->value->data),
58 new Search\FieldType\IntegerField()
59 ),
60 new Search\Field(
61 'sort_value',
62 implode('-', $name),
63 new Search\FieldType\StringField()
64 ),
65 new Search\Field(
66 'fulltext',
67 $name,
68 new Search\FieldType\FullTextField()
69 ),
70 ];
71 }
72
78 public function getIndexDefinition()
79 {
80 return [
81 'name' => new Search\FieldType\MultipleStringField(),
82 'id' => new Search\FieldType\MultipleIntegerField(),
83 'email' => new Search\FieldType\MultipleStringField(),
84 'count' => new Search\FieldType\IntegerField(),
85 'sort_value' => new Search\FieldType\StringField(),
86 ];
87 }
88
98 public function getDefaultMatchField()
99 {
100 return 'name';
101 }
102
112 public function getDefaultSortField()
113 {
114 return 'sort_value';
115 }
116 }
eZ\Publish\Core\FieldType\Author\SearchField
Indexable definition for Author field type.
Definition: Author/SearchField.php:18
eZ\Publish\Core\FieldType\Author\SearchField\getIndexDefinition
getIndexDefinition()
Get index field types for search backend.
Definition: Author/SearchField.php:78
eZ\Publish\Core\FieldType\Author\SearchField\getIndexData
getIndexData(Field $field, FieldDefinition $fieldDefinition)
Get index data for field for search backend.
Definition: Author/SearchField.php:27
eZ\Publish\Core\FieldType\Author\SearchField\getDefaultMatchField
getDefaultMatchField()
Get name of the default field to be used for matching.
Definition: Author/SearchField.php:98
eZ\Publish\Core\FieldType\Author\SearchField\getDefaultSortField
getDefaultSortField()
Get name of the default field to be used for sorting.
Definition: Author/SearchField.php:112
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\Author
Definition: Author.php:7
eZ\Publish\SPI\Search
Definition: Capable.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.