public FieldItemBase::__construct(DataDefinitionInterface $definition, $name = NULL, TypedDataInterface $parent = NULL)
Constructs a TypedData object given its definition and context.
@todo When \Drupal\Core\Config\TypedConfigManager has been fixed to use class-based definitions, type-hint $definition to DataDefinitionInterface. https://www.drupal.org/node/1928868
\Drupal\Core\TypedData\DataDefinitionInterface $definition: The data definition.
string $name: (optional) The name of the created property, or NULL if it is the root of a typed data tree. Defaults to NULL.
\Drupal\Core\TypedData\TypedDataInterface $parent: (optional) The parent object of the data property, or NULL if it is the root of a typed data tree. Defaults to NULL.
Overrides TypedData::__construct
\Drupal\Core\TypedData\TypedDataManager::create()
public function __construct(DataDefinitionInterface $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); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!FieldItemBase.php/function/FieldItemBase::__construct/8.1.x