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

StringMapper.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\SPI\Search\FieldType;
12
16 class StringMapper extends FieldValueMapper
17 {
18 public const REPLACE_WITH_SPACE_PATTERN = '([\x09\x0B\x0C]+)';
19 public const REMOVE_PATTERN = '([\x00-\x08\x0E-\x1F]+)';
20
26 public function canMap(Field $field)
27 {
28 return
29 $field->type instanceof FieldType\StringField;
30 }
31
37 public function map(Field $field)
38 {
39 return $this->convert($field->value);
40 }
41
49 protected function convert($value)
50 {
51 // Replace tab, vertical tab, form-feed chars to single space.
52 $value = preg_replace(
53 self::REPLACE_WITH_SPACE_PATTERN,
54 ' ',
55 (string)$value
56 );
57
58 // Remove non-printable characters.
59 return preg_replace(
60 self::REMOVE_PATTERN,
61 '',
62 (string)$value
63 );
64 }
65 }
eZ\Publish\Core\Search\Common\FieldValueMapper\StringMapper
Common string field value mapper implementation.
Definition: StringMapper.php:17
eZ\Publish\Core\Search\Common\FieldValueMapper\StringMapper\canMap
canMap(Field $field)
Check if field can be mapped.
Definition: StringMapper.php:26
eZ\Publish\Core\Search\Common\FieldValueMapper\StringMapper\REMOVE_PATTERN
const REMOVE_PATTERN
Definition: StringMapper.php:19
eZ\Publish\Core\Search\Common\FieldValueMapper\StringMapper\convert
convert($value)
Convert to a proper search engine representation.
Definition: StringMapper.php:49
eZ\Publish\Core\Search\Common\FieldValueMapper\StringMapper\map
map(Field $field)
Map field value to a proper search engine representation.
Definition: StringMapper.php:37
eZ\Publish\Core\Search\Common\FieldValueMapper\StringMapper\REPLACE_WITH_SPACE_PATTERN
const REPLACE_WITH_SPACE_PATTERN
Definition: StringMapper.php:18
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
eZ\Publish\SPI\Search\FieldType
Definition: BooleanField.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.