function EntityBase::createDuplicate
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::createDuplicate()
- 10 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::createDuplicate()
- 11.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::createDuplicate()
Overrides EntityInterface::createDuplicate
1 call to EntityBase::createDuplicate()
- 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 410
Class
- EntityBase
- Defines a base entity class.
Namespace
Drupal\Core\EntityCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.