public function EntityNG::createDuplicate

Overrides Entity::createDuplicate().

Overrides Entity::createDuplicate

File

drupal/core/lib/Drupal/Core/Entity/EntityNG.php, line 390
Definition of Drupal\Core\Entity\EntityNG.

Class

EntityNG
Implements Entity Field API specific enhancements to the Entity class.

Namespace

Drupal\Core\Entity

Code

public function createDuplicate() {
  $duplicate = clone $this;
  $entity_info = $this
    ->entityInfo();
  $duplicate->{$entity_info['entity_keys']['id']}->value = NULL;

  // Check if the entity type supports UUIDs and generate a new one if so.
  if (!empty($entity_info['entity_keys']['uuid'])) {
    $uuid = new Uuid();
    $duplicate->{$entity_info['entity_keys']['uuid']}->value = $uuid
      ->generate();
  }
  return $duplicate;
}