function FieldConfigBase::getItemDefinition

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::getItemDefinition()
  2. 10 core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::getItemDefinition()
  3. 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 514

Class

FieldConfigBase
Base class for configurable field definitions.

Namespace

Drupal\Core\Field

Code

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.