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

Core/FieldType/Keyword/Type.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\FieldType\Keyword;
8
9 use eZ\Publish\Core\FieldType\FieldType;
10 use eZ\Publish\SPI\Persistence\Content\FieldValue;
11 use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType;
12 use eZ\Publish\SPI\FieldType\Value as SPIValue;
13 use eZ\Publish\Core\FieldType\Value as BaseValue;
14
20 class Type extends FieldType
21 {
27 public function getFieldTypeIdentifier()
28 {
29 return 'ezkeyword';
30 }
31
42 public function getName(SPIValue $value)
43 {
44 return implode(', ', $value->values);
45 }
46
53 public function getEmptyValue()
54 {
55 return new Value([]);
56 }
57
65 protected function createValueFromInput($inputValue)
66 {
67 if (is_string($inputValue)) {
68 $inputValue = [$inputValue];
69 }
70
71 if (is_array($inputValue)) {
72 $inputValue = new Value($inputValue);
73 }
74
75 return $inputValue;
76 }
77
85 protected function checkValueStructure(BaseValue $value)
86 {
87 if (!is_array($value->values)) {
88 throw new InvalidArgumentType(
89 '$value->values',
90 'array',
91 $value->values
92 );
93 }
94 }
95
99 protected function getSortInfo(BaseValue $value)
100 {
101 return implode(',', $value->values);
102 }
103
111 public function fromHash($hash)
112 {
113 return new Value($hash);
114 }
115
123 public function toHash(SPIValue $value)
124 {
125 return $value->values;
126 }
127
133 public function isSearchable()
134 {
135 return true;
136 }
137
145 public function toPersistenceValue(SPIValue $value)
146 {
147 return new FieldValue(
148 [
149 'data' => null,
150 'externalData' => $value->values,
151 'sortKey' => $this->getSortInfo($value),
152 ]
153 );
154 }
155
163 public function fromPersistenceValue(FieldValue $fieldValue)
164 {
165 return new Value($fieldValue->externalData);
166 }
167 }
eZ\Publish\API\Repository\Values\Content\Query\Criterion\Value
Struct that stores extra value information for a Criterion object.
Definition: API/Repository/Values/Content/Query/Criterion/Value.php:13
eZ\Publish\Core\Base\Exceptions\InvalidArgumentType
Invalid Argument Type Exception implementation.
Definition: InvalidArgumentType.php:17
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\Core\FieldType\Keyword\Type
Keyword field types.
Definition: Core/FieldType/Keyword/Type.php:21
eZ\Publish\Core\FieldType\Keyword\Type\createValueFromInput
createValueFromInput($inputValue)
Inspects given $inputValue and potentially converts it into a dedicated value object.
Definition: Core/FieldType/Keyword/Type.php:65
eZ\Publish\Core\FieldType\Keyword\Type\fromHash
fromHash($hash)
Converts an $hash to the Value defined by the field type.
Definition: Core/FieldType/Keyword/Type.php:111
eZ\Publish\Core\FieldType\Keyword\Type\isSearchable
isSearchable()
Returns whether the field type is searchable.
Definition: Core/FieldType/Keyword/Type.php:133
eZ\Publish\Core\FieldType\Keyword\Type\getName
getName(SPIValue $value)
Returns the name of the given field value.
Definition: Core/FieldType/Keyword/Type.php:42
eZ\Publish\Core\FieldType\Keyword\Type\getSortInfo
getSortInfo(BaseValue $value)
{}
Definition: Core/FieldType/Keyword/Type.php:99
eZ\Publish\Core\FieldType\Keyword\Type\checkValueStructure
checkValueStructure(BaseValue $value)
Throws an exception if value structure is not of expected format.
Definition: Core/FieldType/Keyword/Type.php:85
eZ\Publish\Core\FieldType\Keyword\Type\getEmptyValue
getEmptyValue()
Returns the fallback default value of field type when no such default value is provided in the field ...
Definition: Core/FieldType/Keyword/Type.php:53
eZ\Publish\Core\FieldType\Keyword\Type\fromPersistenceValue
fromPersistenceValue(FieldValue $fieldValue)
Converts a persistence $fieldValue to a Value.
Definition: Core/FieldType/Keyword/Type.php:163
eZ\Publish\Core\FieldType\Keyword\Type\getFieldTypeIdentifier
getFieldTypeIdentifier()
Returns the field type identifier for this field type.
Definition: Core/FieldType/Keyword/Type.php:27
eZ\Publish\Core\FieldType\Keyword\Type\toHash
toHash(SPIValue $value)
Converts a $Value to a hash.
Definition: Core/FieldType/Keyword/Type.php:123
eZ\Publish\Core\FieldType\Keyword\Type\toPersistenceValue
toPersistenceValue(SPIValue $value)
Converts a $value to a persistence value.
Definition: Core/FieldType/Keyword/Type.php:145
eZ\Publish\Core\FieldType\Value
Abstract class for all field value classes.
Definition: Core/FieldType/Value.php:17
eZ\Publish\SPI\Persistence\Content\FieldValue
Definition: FieldValue.php:12
eZ\Publish\SPI\FieldType\Value
Interface for field value classes.
Definition: SPI/FieldType/Value.php:13
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.