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

Media/SearchField.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\FieldType\Media;
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 return [
30 new Search\Field(
31 'file_name',
32 $field->value->externalData['fileName'] ?? null,
33 new Search\FieldType\StringField()
34 ),
35 new Search\Field(
36 'file_size',
37 $field->value->externalData['fileSize'] ?? null,
38 new Search\FieldType\IntegerField()
39 ),
40 new Search\Field(
41 'mime_type',
42 $field->value->externalData['mimeType'] ?? null,
43 new Search\FieldType\StringField()
44 ),
45 ];
46 }
47
53 public function getIndexDefinition()
54 {
55 return [
56 'file_name' => new Search\FieldType\StringField(),
57 'file_size' => new Search\FieldType\IntegerField(),
58 'mime_type' => new Search\FieldType\StringField(),
59 ];
60 }
61
71 public function getDefaultMatchField()
72 {
73 return 'file_name';
74 }
75
85 public function getDefaultSortField()
86 {
87 return $this->getDefaultMatchField();
88 }
89 }
eZ\Publish\Core\FieldType\Media\SearchField
Indexable definition for Media field type.
Definition: Media/SearchField.php:18
eZ\Publish\Core\FieldType\Media\SearchField\getIndexDefinition
getIndexDefinition()
Get index field types for search backend.
Definition: Media/SearchField.php:53
eZ\Publish\Core\FieldType\Media\SearchField\getDefaultSortField
getDefaultSortField()
Get name of the default field to be used for sorting.
Definition: Media/SearchField.php:85
eZ\Publish\Core\FieldType\Media\SearchField\getIndexData
getIndexData(Field $field, FieldDefinition $fieldDefinition)
Get index data for field for search backend.
Definition: Media/SearchField.php:27
eZ\Publish\Core\FieldType\Media\SearchField\getDefaultMatchField
getDefaultMatchField()
Get name of the default field to be used for matching.
Definition: Media/SearchField.php:71
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\Search\FieldType
Definition: SPI/Search/FieldType.php:17
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\SPI\Search
Definition: Capable.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.