Same name in other branches
- 2.x src/EntityClone/Content/ContentEntityCloneBase.php \Drupal\entity_clone\EntityClone\Content\ContentEntityCloneBase::setClonedEntityLabel()
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.
array $properties: The properties array.
1 call to ContentEntityCloneBase::setClonedEntityLabel()
- ContentEntityCloneBase::cloneEntity in src/
EntityClone/ Content/ ContentEntityCloneBase.php - Clone an entity.
File
-
src/
EntityClone/ Content/ ContentEntityCloneBase.php, line 173
Class
- ContentEntityCloneBase
- Class Content Entity Clone Base.
Namespace
Drupal\entity_clone\EntityClone\ContentCode
protected function setClonedEntityLabel(EntityInterface $original_entity, EntityInterface $cloned_entity, array $properties) {
$label_key = $this->entityTypeManager
->getDefinition($this->entityTypeId)
->getKey('label');
if ($label_key && $cloned_entity->hasField($label_key)) {
if (isset($properties['no_suffix']) && $properties['no_suffix'] === 1) {
$cloned_entity->set($label_key, $original_entity->label());
}
else {
$languages = $cloned_entity->getTranslationLanguages();
foreach ($languages as $langcode => $language) {
$translation = $cloned_entity->getTranslation($langcode);
$translation->set($label_key, $translation->label() . ' - Cloned');
}
}
}
}