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

Breadcrumb

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

function EntityBase::createDuplicate

Overrides EntityInterface::createDuplicate

2 calls to EntityBase::createDuplicate()
ConfigEntityBase::createDuplicate in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
Creates a duplicate of the entity.
ConfigEntityBase::createDuplicate in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
Creates a duplicate of the entity.
2 methods override EntityBase::createDuplicate()
ConfigEntityBase::createDuplicate in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
Creates a duplicate of the entity.
ContentEntityBase::createDuplicate in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Creates a duplicate of the entity.

File

core/lib/Drupal/Core/Entity/EntityBase.php, line 369

Class

EntityBase
Defines a base entity class.

Namespace

Drupal\Core\Entity

Code

public function createDuplicate() {
    $duplicate = clone $this;
    $entity_type = $this->getEntityType();
    // Reset the entity ID and indicate that this is a new entity.
    $duplicate->{$entity_type->getKey('id')} = NULL;
    $duplicate->enforceIsNew();
    // Check if the entity type supports UUIDs and generate a new one if so.
    if ($entity_type->hasKey('uuid')) {
        $duplicate->{$entity_type->getKey('uuid')} = $this->uuidGenerator()
            ->generate();
    }
    return $duplicate;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal