function FieldConfigBase::getItemDefinition
Same name in other branches
- 9 core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::getItemDefinition()
- 8.9.x core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::getItemDefinition()
- 11.x core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::getItemDefinition()
Overrides ListDataDefinitionInterface::getItemDefinition
File
-
core/
lib/ Drupal/ Core/ Field/ FieldConfigBase.php, line 549
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.