1 entity.class.inc public Entity::createDuplicate()

Implements EntityInterface::createDuplicate().

Overrides EntityInterface::createDuplicate

File

core/modules/entity/entity.class.inc, line 329
Provides an interface and a base class for entities.

Class

Entity
Defines a base entity class.

Code

public function createDuplicate() {
  $entity_info = entity_get_info($this->entityType());
  $duplicate = clone $this;
  $duplicate->{$entity_info['entity keys']['id']} = NULL;
  if (isset($entity_info['entity_keys']['revision'])) {
    $duplicate->{$entity_info['entity keys']['revision']} = NULL;
  }
  return $duplicate;
}