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

Core/FieldType/Rating/Type.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\FieldType\Rating;
8
9 use eZ\Publish\Core\FieldType\FieldType;
10 use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType;
11 use eZ\Publish\SPI\FieldType\Value as SPIValue;
12 use eZ\Publish\Core\FieldType\Value as BaseValue;
13
19 class Type extends FieldType
20 {
27 public function getEmptyValue()
28 {
29 return new Value();
30 }
31
37 public function getFieldTypeIdentifier()
38 {
39 return 'ezsrrating';
40 }
41
52 public function getName(SPIValue $value)
53 {
54 throw new \RuntimeException('Implement this method');
55 }
56
64 public function isEmptyValue(SPIValue $value)
65 {
66 return false;
67 }
68
76 protected function createValueFromInput($inputValue)
77 {
78 if (is_bool($inputValue)) {
79 $inputValue = new Value($inputValue);
80 }
81
82 return $inputValue;
83 }
84
92 protected function checkValueStructure(BaseValue $value)
93 {
94 if (!is_bool($value->isDisabled)) {
95 throw new InvalidArgumentType(
96 '$value->isDisabled',
97 'boolean',
98 $value->isDisabled
99 );
100 }
101 }
102
106 protected function getSortInfo(BaseValue $value)
107 {
108 return false;
109 }
110
118 public function fromHash($hash)
119 {
120 return new Value($hash);
121 }
122
130 public function toHash(SPIValue $value)
131 {
132 return $value->isDisabled;
133 }
134
140 public function isSearchable()
141 {
142 return true;
143 }
144 }
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\Rating\Type
Rating field types.
Definition: Core/FieldType/Rating/Type.php:20
eZ\Publish\Core\FieldType\Rating\Type\getFieldTypeIdentifier
getFieldTypeIdentifier()
Returns the field type identifier for this field type.
Definition: Core/FieldType/Rating/Type.php:37
eZ\Publish\Core\FieldType\Rating\Type\getSortInfo
getSortInfo(BaseValue $value)
{}
Definition: Core/FieldType/Rating/Type.php:106
eZ\Publish\Core\FieldType\Rating\Type\isSearchable
isSearchable()
Returns whether the field type is searchable.
Definition: Core/FieldType/Rating/Type.php:140
eZ\Publish\Core\FieldType\Rating\Type\isEmptyValue
isEmptyValue(SPIValue $value)
Returns if the given $value is considered empty by the field type.
Definition: Core/FieldType/Rating/Type.php:64
eZ\Publish\Core\FieldType\Rating\Type\getName
getName(SPIValue $value)
Returns the name of the given field value.
Definition: Core/FieldType/Rating/Type.php:52
eZ\Publish\Core\FieldType\Rating\Type\createValueFromInput
createValueFromInput($inputValue)
Inspects given $inputValue and potentially converts it into a dedicated value object.
Definition: Core/FieldType/Rating/Type.php:76
eZ\Publish\Core\FieldType\Rating\Type\checkValueStructure
checkValueStructure(BaseValue $value)
Throws an exception if value structure is not of expected format.
Definition: Core/FieldType/Rating/Type.php:92
eZ\Publish\Core\FieldType\Rating\Type\getEmptyValue
getEmptyValue()
Returns the fallback default value of field type when no such default value is provided in the field ...
Definition: Core/FieldType/Rating/Type.php:27
eZ\Publish\Core\FieldType\Rating\Type\toHash
toHash(SPIValue $value)
Converts a $Value to a hash.
Definition: Core/FieldType/Rating/Type.php:130
eZ\Publish\Core\FieldType\Rating\Type\fromHash
fromHash($hash)
Converts an $hash to the Value defined by the field type.
Definition: Core/FieldType/Rating/Type.php:118
eZ\Publish\Core\FieldType\Rating\Value
Value for Rating field type.
Definition: Core/FieldType/Rating/Value.php:15
eZ\Publish\Core\FieldType\Value
Abstract class for all field value classes.
Definition: Core/FieldType/Value.php:17
eZ\Publish\SPI\FieldType\Value
Interface for field value classes.
Definition: SPI/FieldType/Value.php:13
eZ\Publish\Core\FieldType\Rating
Definition: Core/FieldType/Rating/Type.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.