function BaseFieldDefinition::__clone
Same name in other branches
- 9 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::__clone()
- 8.9.x core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::__clone()
- 10 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::__clone()
Magic method: Implements a deep clone.
Overrides ListDataDefinition::__clone
File
-
core/
lib/ Drupal/ Core/ Field/ BaseFieldDefinition.php, line 816
Class
- BaseFieldDefinition
- A class for defining entity fields.
Namespace
Drupal\Core\FieldCode
public function __clone() {
parent::__clone();
// The itemDefinition (\Drupal\Core\Field\TypedData\FieldItemDataDefinition)
// has a property fieldDefinition, which is a recursive reference to the
// parent BaseFieldDefinition, therefore the reference to the old object has
// to be overwritten with a reference to the cloned one.
$this->itemDefinition
->setFieldDefinition($this);
// Reset the static cache of the field property definitions in order to
// ensure that the clone will reference different field property definitions
// objects.
$this->propertyDefinitions = NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.