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

Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
eZ\Publish\Core\FieldType\Relation\Type Class Reference

The Relation field type. More...

Inheritance diagram for eZ\Publish\Core\FieldType\Relation\Type:

## Public Member Functions
| __construct (TargetContentValidatorInterface $targetContentValidator)
| validateFieldSettings ($fieldSettings)
| getFieldTypeIdentifier ()
| Returns the field type identifier for this field type. More...
| getName (SPIValue $value)
| Returns the name of the given field value. More...
| validate (FieldDefinition $fieldDefinition, SPIValue $fieldValue)
| Validates a field based on the validators in the field definition. More...
| getEmptyValue ()
| Returns the fallback default value of field type when no such default value is provided in the field definition in content types. More...
| isEmptyValue (SPIValue $value)
| Returns if the given $value is considered empty by the field type. More...
| fromHash ($hash)
| Converts an $hash to the Value defined by the field type. More...
| toHash (SPIValue $value)
| Converts a $Value to a hash. More...
| isSearchable ()
| Returns whether the field type is searchable. More...
| getRelations (SPIValue $fieldValue)
| Returns relation data extracted from value. More...
Public Member Functions inherited from eZ\Publish\Core\FieldType\FieldType
| setTransformationProcessor (TransformationProcessor $transformationProcessor)
| getSettingsSchema ()
| Returns a schema for the settings expected by the FieldType. More...
| getValidatorConfigurationSchema ()
| Returns a schema for the validator configuration expected by the FieldType. More...
| validateValidatorConfiguration ($validatorConfiguration)
| Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct. More...
| applyDefaultValidatorConfiguration (&$validatorConfiguration)
| Applies the default values to the given $validatorConfiguration of a FieldDefinitionCreateStruct. More...
| applyDefaultSettings (&$fieldSettings)
| Applies the default values to the fieldSettings of a FieldDefinitionCreateStruct. More...
| toPersistenceValue (SPIValue $value)
| Converts a $value to a persistence value. More...
| fromPersistenceValue (PersistenceValue $fieldValue)
| Converts a persistence $fieldValue to a Value. More...
| isSingular ()
| Indicates if the field definition of this type can appear only once in the same ContentType. More...
| onlyEmptyInstance ()
| Indicates if the field definition of this type can be added to a ContentType with Content instances. More...
| acceptValue ($inputValue)
| Potentially builds and checks the type and structure of the $inputValue. More...
| fieldSettingsToHash ($fieldSettings)
| Converts the given $fieldSettings to a simple hash format. More...
| fieldSettingsFromHash ($fieldSettingsHash)
| Converts the given $fieldSettingsHash to field settings of the type. More...
| validatorConfigurationToHash ($validatorConfiguration)
| Converts the given $validatorConfiguration to a simple hash format. More...
| validatorConfigurationFromHash ($validatorConfigurationHash)
| Converts the given $validatorConfigurationHash to a validator configuration of the type. More...
| valuesEqual (SPIValue $value1, SPIValue $value2)
Public Member Functions inherited from eZ\Publish\SPI\FieldType\FieldType
| getName (Value $value)
| Returns a human readable string representation from the given $value. More...
| validate (FieldDefinition $fieldDef, Value $value)
| Validates a field based on the validator configuration in the field definition. More...
| isEmptyValue (Value $value)
| Returns if the given $value is considered empty by the field type. More...
| toHash (Value $value)
| Converts the given $value into a plain hash format. More...
| toPersistenceValue (Value $value)
| Converts a $value to a persistence value. More...
| fromPersistenceValue (FieldValue $fieldValue)
| Converts a persistence $value to a Value. More...
| getRelations (Value $value)
| Returns relation data extracted from value. More...
Public Member Functions inherited from eZ\Publish\SPI\FieldType\Comparable
| valuesEqual (Value $value1, Value $value2)

## Public Attributes
const | SELECTION_BROWSE = 0
const | SELECTION_DROPDOWN = 1

## Protected Member Functions
| createValueFromInput ($inputValue)
| Inspects given $inputValue and potentially converts it into a dedicated value object. More...
| checkValueStructure (BaseValue $value)
| Throws an exception if value structure is not of expected format. More...
| getSortInfo (BaseValue $value)
| Returns information for FieldValue->$sortKey relevant to the field type. More...
Protected Member Functions inherited from eZ\Publish\Core\FieldType\FieldType
| getSortInfo (Value $value)
| Returns information for FieldValue->$sortKey relevant to the field type. More...
| checkValueStructure (Value $value)
| Throws an exception if value structure is not of expected format. More...

## Protected Attributes
| $settingsSchema
Protected Attributes inherited from eZ\Publish\Core\FieldType\FieldType
| $settingsSchema = []
| $validatorConfigurationSchema = []
| $transformationProcessor

## Private Attributes
| $targetContentValidator

## Additional Inherited Members
Static Protected Member Functions inherited from eZ\Publish\Core\FieldType\FieldType
static | checkValueType ($value)
| Throws an exception if the given $value is not an instance of the supported value subtype. More...

## Detailed Description

The Relation field type.

This field type represents a relation to a content.

hash format ({

See also
  fromhash()}, {
  toHash()}): array( 'destinationContentId' => (int)$destinationContentId );

Deprecated:
  Since 7.0 and will be removed in 8.0. Use `RelationList\Type` instead.

Definition at line 29 of file Core/FieldType/Relation/Type.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZ\Publish\Core\FieldType\Relation\Type::__construct | ( | TargetContentValidatorInterface | $targetContentValidator | ) |

Definition at line 52 of file Core/FieldType/Relation/Type.php.

References eZ\Publish\Core\FieldType\Relation\Type\$targetContentValidator.

## Member Function Documentation

## ◆ checkValueStructure()

eZ\Publish\Core\FieldType\Relation\Type::checkValueStructure | ( | BaseValue | $value | ) |
| protected

Throws an exception if value structure is not of expected format.

Exceptions

Definition at line 223 of file Core/FieldType/Relation/Type.php.

## ◆ createValueFromInput()

eZ\Publish\Core\FieldType\Relation\Type::createValueFromInput | ( |  | $inputValue | ) |
| protected

Inspects given $inputValue and potentially converts it into a dedicated value object.

Parameters

  int | string | \eZ\Publish\API\Repository\Values\Content\ContentInfo | \eZ\Publish\Core\FieldType\Relation\Value | $inputValue |

Returns
  \eZ\Publish\Core\FieldType\Relation\Value The potentially converted and structurally plausible value.

Reimplemented from eZ\Publish\Core\FieldType\FieldType.

Definition at line 204 of file Core/FieldType/Relation/Type.php.

## ◆ fromHash()

eZ\Publish\Core\FieldType\Relation\Type::fromHash | ( |  | $hash | ) |

Converts an $hash to the Value defined by the field type.

Parameters

  mixed | $hash |

Returns
  \eZ\Publish\Core\FieldType\Relation\Value $value

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 254 of file Core/FieldType/Relation/Type.php.

References eZ\Publish\Core\FieldType\Relation\Type\getEmptyValue().

## ◆ getEmptyValue()

eZ\Publish\Core\FieldType\Relation\Type::getEmptyValue | ( |  | ) |

Returns the fallback default value of field type when no such default value is provided in the field definition in content types.

Returns
  \eZ\Publish\Core\FieldType\Relation\Value

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 180 of file Core/FieldType/Relation/Type.php.

Referenced by eZ\Publish\Core\FieldType\Relation\Type\fromHash().

## ◆ getFieldTypeIdentifier()

eZ\Publish\Core\FieldType\Relation\Type::getFieldTypeIdentifier | ( |  | ) |

Returns the field type identifier for this field type.

Returns
  string

Implements eZ\Publish\SPI\FieldType\FieldType.

Definition at line 131 of file Core/FieldType/Relation/Type.php.

## ◆ getName()

eZ\Publish\Core\FieldType\Relation\Type::getName | ( | SPIValue | $value | ) |

Returns the name of the given field value.

It will be used to generate content name and url alias if current field is designated to be used in the content name/urlAlias pattern.

Parameters

  \eZ\Publish\Core\FieldType\Relation\Value | $value |

Returns
  string

Definition at line 146 of file Core/FieldType/Relation/Type.php.

## ◆ getRelations()

eZ\Publish\Core\FieldType\Relation\Type::getRelations | ( | SPIValue | $fieldValue | ) |

Returns relation data extracted from value.

Not intended for \eZ\Publish\API\Repository\Values\Content\Relation::COMMON type relations, there is an API for handling those.

Parameters

  \eZ\Publish\Core\FieldType\Relation\Value | $fieldValue |

Returns
  array Hash with relation type as key and array of destination content ids as value.

Example: `array( \eZ\Publish\API\Repository\Values\Content\Relation::LINK => array( "contentIds" => array( 12, 13, 14 ), "locationIds" => array( 24 ) ), \eZ\Publish\API\Repository\Values\Content\Relation::EMBED => array( "contentIds" => array( 12 ), "locationIds" => array( 24, 45 ) ), \eZ\Publish\API\Repository\Values\Content\Relation::FIELD => array( 12 ) )`

Reimplemented from eZ\Publish\Core\FieldType\FieldType.

Definition at line 313 of file Core/FieldType/Relation/Type.php.

References eZ\Publish\API\Repository\Values\Content\Relation\FIELD.

## ◆ getSortInfo()

eZ\Publish\Core\FieldType\Relation\Type::getSortInfo | ( | BaseValue | $value | ) |
| protected

Returns information for FieldValue->$sortKey relevant to the field type.

For this FieldType, the related object's name is returned.

Parameters

  \eZ\Publish\Core\FieldType\Relation\Value | $value |

Returns
  string

Definition at line 242 of file Core/FieldType/Relation/Type.php.

## ◆ isEmptyValue()

eZ\Publish\Core\FieldType\Relation\Type::isEmptyValue | ( | SPIValue | $value | ) |

Returns if the given $value is considered empty by the field type.

Parameters

  mixed | $value |

Returns
  bool

Reimplemented from eZ\Publish\Core\FieldType\FieldType.

Definition at line 192 of file Core/FieldType/Relation/Type.php.

Referenced by eZ\Publish\Core\FieldType\Relation\Type\validate().

## ◆ isSearchable()

eZ\Publish\Core\FieldType\Relation\Type::isSearchable | ( |  | ) |

Returns whether the field type is searchable.

Returns
  bool

Reimplemented from eZ\Publish\Core\FieldType\FieldType.

Definition at line 283 of file Core/FieldType/Relation/Type.php.

## ◆ toHash()

eZ\Publish\Core\FieldType\Relation\Type::toHash | ( | SPIValue | $value | ) |

Converts a $Value to a hash.

Parameters

  \eZ\Publish\Core\FieldType\Relation\Value | $value |

Returns
  mixed

Definition at line 273 of file Core/FieldType/Relation/Type.php.

## ◆ validate()

eZ\Publish\Core\FieldType\Relation\Type::validate | ( | FieldDefinition | $fieldDefinition,
|  | SPIValue | $fieldValue
| ) |  |

Validates a field based on the validators in the field definition.

Returns
  \eZ\Publish\SPI\FieldType\ValidationError[]

Reimplemented from eZ\Publish\Core\FieldType\FieldType.

Definition at line 156 of file Core/FieldType/Relation/Type.php.

References eZ\Publish\API\Repository\Values\ContentType\FieldDefinition\getFieldSettings(), and eZ\Publish\Core\FieldType\Relation\Type\isEmptyValue().

## ◆ validateFieldSettings()

eZ\Publish\Core\FieldType\Relation\Type::validateFieldSettings | ( |  | $fieldSettings | ) |

See also
  \eZ\Publish\Core\FieldType\FieldType::validateFieldSettings()

Parameters

  mixed | $fieldSettings |

Returns
  \eZ\Publish\SPI\FieldType\ValidationError[]

Reimplemented from eZ\Publish\Core\FieldType\FieldType.

Definition at line 64 of file Core/FieldType/Relation/Type.php.

## Member Data Documentation

## ◆ $settingsSchema

eZ\Publish\Core\FieldType\Relation\Type::$settingsSchema
| protected

Initial value:
= [
'selectionMethod' => [
'type' => 'int',
'default' => self::SELECTION_BROWSE,
],
'selectionRoot' => [
'type' => 'string',
'default' => null,
],
'selectionContentTypes' => [
'type' => 'array',
'default' => [],
],
]
eZ\Publish\Core\FieldType\Relation\Type\SELECTION_BROWSE
const SELECTION_BROWSE
Definition: Core/FieldType/Relation/Type.php:31

Definition at line 34 of file Core/FieldType/Relation/Type.php.

## ◆ $targetContentValidator

eZ\Publish\Core\FieldType\Relation\Type::$targetContentValidator
| private

Definition at line 50 of file Core/FieldType/Relation/Type.php.

Referenced by eZ\Publish\Core\FieldType\Relation\Type\__construct().

## ◆ SELECTION_BROWSE

const eZ\Publish\Core\FieldType\Relation\Type::SELECTION_BROWSE = 0

Definition at line 31 of file Core/FieldType/Relation/Type.php.

## ◆ SELECTION_DROPDOWN

const eZ\Publish\Core\FieldType\Relation\Type::SELECTION_DROPDOWN = 1

Definition at line 32 of file Core/FieldType/Relation/Type.php.

The documentation for this class was generated from the following file:

- Core/FieldType/Relation/Type.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.