Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BaseFieldDefinition.php

function 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\Field

Code

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;
}
RSS feed
Powered by Drupal