Same name in other branches
- 2.x src/EntityClone/Content/FileEntityClone.php \Drupal\entity_clone\EntityClone\Content\FileEntityClone
Class ContentEntityCloneBase.
Hierarchy
- class \Drupal\entity_clone\EntityClone\Content\ContentEntityCloneBase implements \Drupal\Core\Entity\EntityHandlerInterface, \Drupal\entity_clone\EntityClone\EntityCloneInterface
- class \Drupal\entity_clone\EntityClone\Content\FileEntityClone extends \Drupal\entity_clone\EntityClone\Content\ContentEntityCloneBase
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 = \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);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
ContentEntityCloneBase::$currentUser | protected | property | The current user. | |
ContentEntityCloneBase::$entityTypeId | protected | property | The entity type ID. | |
ContentEntityCloneBase::$entityTypeManager | protected | property | The entity type manager. | |
ContentEntityCloneBase::$timeService | protected | property | A service for obtaining the system's time. | |
ContentEntityCloneBase::cloneReferencedEntities | protected | function | Clones referenced entities. | |
ContentEntityCloneBase::createInstance | public static | function | ||
ContentEntityCloneBase::fieldIsClonable | protected | function | Determines if a field is clonable. | |
ContentEntityCloneBase::getChildProperties | protected | function | Fetches the properties of a child entity. | |
ContentEntityCloneBase::hasTranslatableModerationState | protected | function | Checks if the entity has the moderation state field and can be moderated. | |
ContentEntityCloneBase::setClonedEntityLabel | protected | function | Sets the cloned entity's label. | |
ContentEntityCloneBase::setCreatedAndChangedDates | protected | function | Resets the created and changed dates on the cloned entity. | |
ContentEntityCloneBase::setTranslationModerationState | protected | function | Create moderation_state translations for the cloned entities. | |
ContentEntityCloneBase::__construct | public | function | Constructs a new ContentEntityCloneBase. | |
FileEntityClone::cloneEntity | public | function | Clone an entity. | Overrides ContentEntityCloneBase::cloneEntity |