function FieldItemBase::__construct

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::__construct()
  2. 8.9.x core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::__construct()
  3. 11.x core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::__construct()

Overrides TypedData::__construct

1 call to FieldItemBase::__construct()
FieldTestItem::__construct in core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php
2 methods override FieldItemBase::__construct()
FieldItemTestClass::__construct in core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php
FieldTestItem::__construct in core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php

File

core/lib/Drupal/Core/Field/FieldItemBase.php, line 60

Class

FieldItemBase
An entity field item.

Namespace

Drupal\Core\Field

Code

public function __construct(ComplexDataDefinitionInterface $definition, $name = NULL, ?TypedDataInterface $parent = NULL) {
    parent::__construct($definition, $name, $parent);
    // Initialize computed properties by default, such that they get cloned
    // with the whole item.
    foreach ($this->definition
        ->getPropertyDefinitions() as $name => $definition) {
        if ($definition->isComputed()) {
            $this->properties[$name] = \Drupal::typedDataManager()->getPropertyInstance($this, $name);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.