$duplicate =
clone $this;
$entity_type =
$this->
getEntityType();
if ($entity_type->
hasKey('id'
)) { $duplicate->
{$entity_type->
getKey('id'
)}->value = 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'
)}->value =
$this->
uuidGenerator()->
generate();
} // Check whether the entity type supports revisions and initialize it if so.
if ($entity_type->
isRevisionable()) { $duplicate->
{$entity_type->
getKey('revision'
)}->value = NULL;
$duplicate->loadedRevisionId = NULL;
} return $duplicate;
}