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

Search/Common/FieldValueMapper/Aggregate.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Search\Common\FieldValueMapper;
8
9 use eZ\Publish\Core\Search\Common\FieldValueMapper;
10 use eZ\Publish\SPI\Search\Field;
11 use eZ\Publish\API\Repository\Exceptions\NotImplementedException;
12
16 class Aggregate extends FieldValueMapper
17 {
23 protected $mappers = [];
24
30 public function __construct(array $mappers = [])
31 {
32 foreach ($mappers as $mapper) {
33 $this->addMapper($mapper);
34 }
35 }
36
42 public function addMapper(FieldValueMapper $mapper)
43 {
44 $this->mappers[] = $mapper;
45 }
46
54 public function canMap(Field $field)
55 {
56 return true;
57 }
58
68 public function map(Field $field)
69 {
70 foreach ($this->mappers as $mapper) {
71 if ($mapper->canMap($field)) {
72 return $mapper->map($field);
73 }
74 }
75
76 throw new NotImplementedException(
77 'No mapper available for: ' . get_class($field->type)
78 );
79 }
80 }
eZ\Publish\API\Repository\Exceptions\NotImplementedException
This Exception is thrown if a feature has not been implemented intentionally.
Definition: API/Repository/Exceptions/NotImplementedException.php:15
eZ\Publish\Core\Search\Common\FieldValueMapper\Aggregate
Common aggregate mapper implementation.
Definition: Search/Common/FieldValueMapper/Aggregate.php:17
eZ\Publish\Core\Search\Common\FieldValueMapper\Aggregate\map
map(Field $field)
Map field value to a proper search engine representation.
Definition: Search/Common/FieldValueMapper/Aggregate.php:68
eZ\Publish\Core\Search\Common\FieldValueMapper\Aggregate\addMapper
addMapper(FieldValueMapper $mapper)
Adds mapper.
Definition: Search/Common/FieldValueMapper/Aggregate.php:42
eZ\Publish\Core\Search\Common\FieldValueMapper\Aggregate\$mappers
$mappers
Definition: Search/Common/FieldValueMapper/Aggregate.php:23
eZ\Publish\Core\Search\Common\FieldValueMapper\Aggregate\__construct
__construct(array $mappers=[])
Construct from optional mapper array.
Definition: Search/Common/FieldValueMapper/Aggregate.php:30
eZ\Publish\Core\Search\Common\FieldValueMapper\Aggregate\canMap
canMap(Field $field)
Check if field can be mapped.
Definition: Search/Common/FieldValueMapper/Aggregate.php:54
eZ\Publish\Core\Search\Common\FieldValueMapper
Maps raw field values to something search engine can understand.
Definition: FieldValueMapper.php:21
eZ\Publish\SPI\Search\Field
Definition: SPI/Search/Field.php:19
eZ\Publish\Core\Search\Common\FieldValueMapper
Definition: Search/Common/FieldValueMapper/Aggregate.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.