You are here

class FieldConfigEntityClone in Entity Clone 8

Class FieldConfigEntityClone.

Hierarchy

Expanded class hierarchy of FieldConfigEntityClone

1 file declares its use of FieldConfigEntityClone
entity_clone.module in ./entity_clone.module
Contains entity_clone.module.

File

src/EntityClone/Config/FieldConfigEntityClone.php, line 10

Namespace

Drupal\entity_clone\EntityClone\Config
View source
class FieldConfigEntityClone extends ConfigEntityCloneBase {

  /**
   * {@inheritdoc}
   */
  public function cloneEntity(EntityInterface $field_config, EntityInterface $cloned_field_config, array $properties = []) {

    /** @var \Drupal\field\Entity\FieldConfig $field_config */

    /** @var \Drupal\field\Entity\FieldConfig $cloned_field_config */

    /** @var \Drupal\field\Entity\FieldStorageConfig $cloned_field_storage */
    if (!isset($properties['skip_storage']) || !$properties['skip_storage']) {
      $cloned_field_storage = $field_config
        ->getFieldStorageDefinition()
        ->createDuplicate();
      $cloned_field_storage
        ->set('field_name', $properties['id']);
      $cloned_field_storage
        ->set('id', $properties['id'] . '.' . $cloned_field_storage
        ->getTargetEntityTypeId());
      $cloned_field_storage
        ->save();
    }
    unset($properties['skip_storage']);
    $properties['field_name'] = $properties['id'];
    $properties['id'] = $cloned_field_config
      ->getTargetEntityTypeId() . '.' . $cloned_field_config
      ->getTargetBundle() . '.' . $properties['id'];
    return parent::cloneEntity($field_config, $cloned_field_config, $properties);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEntityCloneBase::$entityTypeId protected property The entity type ID.
ConfigEntityCloneBase::$entityTypeManager protected property The entity type manager.
ConfigEntityCloneBase::createInstance public static function Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface::createInstance 1
ConfigEntityCloneBase::__construct public function Constructs a new ConfigEntityCloneBase. 1
FieldConfigEntityClone::cloneEntity public function Clone an entity. Overrides ConfigEntityCloneBase::cloneEntity