class FileEntityClone in Entity Clone 8
Class ContentEntityCloneBase.
Hierarchy
- class \Drupal\entity_clone\EntityClone\Content\ContentEntityCloneBase implements EntityHandlerInterface, EntityCloneInterface
- class \Drupal\entity_clone\EntityClone\Content\FileEntityClone
Expanded class hierarchy of FileEntityClone
1 file declares its use of FileEntityClone
- entity_clone.module in ./
entity_clone.module - Contains entity_clone.module.
File
- src/
EntityClone/ Content/ FileEntityClone.php, line 11
Namespace
Drupal\entity_clone\EntityClone\ContentView source
class FileEntityClone extends ContentEntityCloneBase {
/**
* {@inheritdoc}
*/
public function cloneEntity(EntityInterface $entity, EntityInterface $cloned_entity, array $properties = [], array &$already_cloned = []) {
/** @var \Drupal\file\FileInterface $cloned_entity */
$cloned_file = file_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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentEntityCloneBase:: |
protected | property | The current user. | |
ContentEntityCloneBase:: |
protected | property | The entity type ID. | |
ContentEntityCloneBase:: |
protected | property | The entity type manager. | |
ContentEntityCloneBase:: |
protected | property | A service for obtaining the system's time. | |
ContentEntityCloneBase:: |
protected | function | Clones referenced entities. | |
ContentEntityCloneBase:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface:: |
|
ContentEntityCloneBase:: |
protected | function | Determines if a field is clonable. | |
ContentEntityCloneBase:: |
protected | function | Fetches the properties of a child entity. | |
ContentEntityCloneBase:: |
protected | function | Sets the cloned entity's label. | |
ContentEntityCloneBase:: |
public | function | Constructs a new ContentEntityCloneBase. | |
FileEntityClone:: |
public | function |
Clone an entity. Overrides ContentEntityCloneBase:: |