Same name in other branches
- 8.x-1.x src/EntityClone/Content/FileEntityClone.php \Drupal\entity_clone\EntityClone\Content\FileEntityClone::cloneEntity()
Overrides ContentEntityCloneBase::cloneEntity
Fichier
-
src/
EntityClone/ Content/ FileEntityClone.php, line 16
Classe
- FileEntityClone
- Class ContentEntityCloneBase.
Namespace
Drupal\entity_clone\EntityClone\ContentCode
public function cloneEntity(EntityInterface $entity, EntityInterface $cloned_entity, array $properties = [], array &$already_cloned = []) {
/** @var \Drupal\file\FileInterface $cloned_entity */
$cloned_file = \Drupal::service('file.repository')->copy($cloned_entity, $cloned_entity->getFileUri(), FileSystemInterface::EXISTS_RENAME);
if (isset($properties['take_ownership']) && $properties['take_ownership'] === 1) {
$cloned_file->setOwnerId(\Drupal::currentUser()->id());
}
return parent::cloneEntity($entity, $cloned_file, $properties);
}