public function BaseFieldDefinition::__clone in Drupal 9
Same name and namespace in other branches
- 8 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 815
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;
}