TrashItem.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Files_Trashbin\Trash;
  7. use OCP\Files\FileInfo;
  8. use OCP\IUser;
  9. class TrashItem implements ITrashItem {
  10. public function __construct(
  11. private ITrashBackend $backend,
  12. private string $originalLocation,
  13. private int $deletedTime,
  14. private string $trashPath,
  15. private FileInfo $fileInfo,
  16. private IUser $user,
  17. private ?IUser $deletedBy,
  18. ) {
  19. }
  20. public function getTrashBackend(): ITrashBackend {
  21. return $this->backend;
  22. }
  23. public function getOriginalLocation(): string {
  24. return $this->originalLocation;
  25. }
  26. public function getDeletedTime(): int {
  27. return $this->deletedTime;
  28. }
  29. public function getTrashPath(): string {
  30. return $this->trashPath;
  31. }
  32. public function isRootItem(): bool {
  33. return substr_count($this->getTrashPath(), '/') === 1;
  34. }
  35. public function getUser(): IUser {
  36. return $this->user;
  37. }
  38. public function getEtag() {
  39. return $this->fileInfo->getEtag();
  40. }
  41. public function getSize($includeMounts = true) {
  42. return $this->fileInfo->getSize($includeMounts);
  43. }
  44. public function getMtime() {
  45. return $this->fileInfo->getMtime();
  46. }
  47. public function getName() {
  48. return $this->fileInfo->getName();
  49. }
  50. public function getInternalPath() {
  51. return $this->fileInfo->getInternalPath();
  52. }
  53. public function getPath() {
  54. return $this->fileInfo->getPath();
  55. }
  56. public function getMimetype() {
  57. return $this->fileInfo->getMimetype();
  58. }
  59. public function getMimePart() {
  60. return $this->fileInfo->getMimePart();
  61. }
  62. public function getStorage() {
  63. return $this->fileInfo->getStorage();
  64. }
  65. public function getId() {
  66. return $this->fileInfo->getId();
  67. }
  68. public function isEncrypted() {
  69. return $this->fileInfo->isEncrypted();
  70. }
  71. public function getPermissions() {
  72. return $this->fileInfo->getPermissions();
  73. }
  74. public function getType() {
  75. return $this->fileInfo->getType();
  76. }
  77. public function isReadable() {
  78. return $this->fileInfo->isReadable();
  79. }
  80. public function isUpdateable() {
  81. return $this->fileInfo->isUpdateable();
  82. }
  83. public function isCreatable() {
  84. return $this->fileInfo->isCreatable();
  85. }
  86. public function isDeletable() {
  87. return $this->fileInfo->isDeletable();
  88. }
  89. public function isShareable() {
  90. return $this->fileInfo->isShareable();
  91. }
  92. public function isShared() {
  93. return $this->fileInfo->isShared();
  94. }
  95. public function isMounted() {
  96. return $this->fileInfo->isMounted();
  97. }
  98. public function getMountPoint() {
  99. return $this->fileInfo->getMountPoint();
  100. }
  101. public function getOwner() {
  102. return $this->fileInfo->getOwner();
  103. }
  104. public function getChecksum() {
  105. return $this->fileInfo->getChecksum();
  106. }
  107. public function getExtension(): string {
  108. return $this->fileInfo->getExtension();
  109. }
  110. public function getTitle(): string {
  111. return $this->getOriginalLocation();
  112. }
  113. public function getCreationTime(): int {
  114. return $this->fileInfo->getCreationTime();
  115. }
  116. public function getUploadTime(): int {
  117. return $this->fileInfo->getUploadTime();
  118. }
  119. public function getParentId(): int {
  120. return $this->fileInfo->getParentId();
  121. }
  122. public function getDeletedBy(): ?IUser {
  123. return $this->deletedBy;
  124. }
  125. /**
  126. * @inheritDoc
  127. * @return array<string, int|string|bool|float|string[]|int[]>
  128. */
  129. public function getMetadata(): array {
  130. return $this->fileInfo->getMetadata();
  131. }
  132. }