public function FieldConfigBase::getItemDefinition in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::getItemDefinition()
- 9 core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::getItemDefinition()
Gets the data definition of an item of the list.
Return value
\Drupal\Core\TypedData\DataDefinitionInterface A data definition describing the list items.
Overrides ListDataDefinitionInterface::getItemDefinition
File
- core/
lib/ Drupal/ Core/ Field/ FieldConfigBase.php, line 514
Class
- FieldConfigBase
- Base class for configurable field definitions.
Namespace
Drupal\Core\FieldCode
public function getItemDefinition() {
if (!isset($this->itemDefinition)) {
$this->itemDefinition = FieldItemDataDefinition::create($this)
->setSettings($this
->getSettings());
// Add any custom property constraints, overwriting as required.
$item_constraints = $this->itemDefinition
->getConstraint('ComplexData') ?: [];
foreach ($this->propertyConstraints as $name => $constraints) {
if (isset($item_constraints[$name])) {
$item_constraints[$name] = $constraints + $item_constraints[$name];
}
else {
$item_constraints[$name] = $constraints;
}
$this->itemDefinition
->addConstraint('ComplexData', $item_constraints);
}
}
return $this->itemDefinition;
}