protected function ContentEntityCloneBase::setClonedEntityLabel in Entity Clone 8
Sets the cloned entity's label.
Parameters
\Drupal\Core\Entity\EntityInterface $original_entity: The original entity.
\Drupal\Core\Entity\EntityInterface $cloned_entity: The entity cloned from the original.
1 call to ContentEntityCloneBase::setClonedEntityLabel()
- ContentEntityCloneBase::cloneEntity in src/
EntityClone/ Content/ ContentEntityCloneBase.php - Clone an entity.
File
- src/
EntityClone/ Content/ ContentEntityCloneBase.php, line 149
Class
- ContentEntityCloneBase
- Class ContentEntityCloneBase.
Namespace
Drupal\entity_clone\EntityClone\ContentCode
protected function setClonedEntityLabel(EntityInterface $original_entity, EntityInterface $cloned_entity) {
$label_key = $this->entityTypeManager
->getDefinition($this->entityTypeId)
->getKey('label');
if ($label_key && $cloned_entity
->hasField($label_key)) {
$cloned_entity
->set($label_key, $original_entity
->label() . ' - Cloned');
}
}