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

Selection/NameableField.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\FieldType\Selection;
8
9 use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
10 use eZ\Publish\SPI\FieldType\Nameable;
11 use eZ\Publish\SPI\FieldType\Value as SPIValue;
12
16 class NameableField implements Nameable
17 {
25 public function getFieldName(SPIValue $value, FieldDefinition $fieldDefinition, $languageCode)
26 {
27 if (empty($value->selection)) {
28 return '';
29 }
30
31 $names = [];
32 $fieldSettings = $fieldDefinition->getFieldSettings();
33
34 foreach ($value->selection as $optionIndex) {
35 if (isset($fieldSettings['multilingualOptions'][$languageCode][$optionIndex])) {
36 $names[] = $fieldSettings['multilingualOptions'][$languageCode][$optionIndex];
37 } elseif (isset($fieldSettings['multilingualOptions'][$fieldDefinition->mainLanguageCode][$optionIndex])) {
38 $names[] = $fieldSettings['multilingualOptions'][$fieldDefinition->mainLanguageCode][$optionIndex];
39 } elseif (isset($fieldSettings['options'][$optionIndex])) {
40 $names[] = $fieldSettings['options'][$optionIndex];
41 }
42 }
43
44 return implode(' ', $names);
45 }
46 }
eZ\Publish\API\Repository\Values\ContentType\FieldDefinition
Definition: API/Repository/Values/ContentType/FieldDefinition.php:31
eZ\Publish\API\Repository\Values\ContentType\FieldDefinition\getFieldSettings
getFieldSettings()
This method returns settings for the field definition supported by the field type.
eZ\Publish\Core\FieldType\Selection\NameableField
Class NameableField for Selection FieldType.
Definition: Selection/NameableField.php:17
eZ\Publish\Core\FieldType\Selection\NameableField\getFieldName
getFieldName(SPIValue $value, FieldDefinition $fieldDefinition, $languageCode)
Definition: Selection/NameableField.php:25
eZ\Publish\SPI\FieldType\Nameable
The field type interface which all field types have to implement to be able to generate content name ...
Definition: Nameable.php:36
eZ\Publish\SPI\FieldType\Value
Interface for field value classes.
Definition: SPI/FieldType/Value.php:13
eZ\Publish\Core\FieldType\Selection
Definition: Selection/NameableField.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.