TrashItem.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
  4. *
  5. * @author Maxence Lange <maxence@artificial-owl.com>
  6. * @author Robin Appelman <robin@icewind.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\Files_Trashbin\Trash;
  25. use OCP\Files\FileInfo;
  26. use OCP\IUser;
  27. class TrashItem implements ITrashItem {
  28. public function __construct(
  29. private ITrashBackend $backend,
  30. private string $originalLocation,
  31. private int $deletedTime,
  32. private string $trashPath,
  33. private FileInfo $fileInfo,
  34. private IUser $user,
  35. private ?IUser $deletedBy,
  36. ) {
  37. }
  38. public function getTrashBackend(): ITrashBackend {
  39. return $this->backend;
  40. }
  41. public function getOriginalLocation(): string {
  42. return $this->originalLocation;
  43. }
  44. public function getDeletedTime(): int {
  45. return $this->deletedTime;
  46. }
  47. public function getTrashPath(): string {
  48. return $this->trashPath;
  49. }
  50. public function isRootItem(): bool {
  51. return substr_count($this->getTrashPath(), '/') === 1;
  52. }
  53. public function getUser(): IUser {
  54. return $this->user;
  55. }
  56. public function getEtag() {
  57. return $this->fileInfo->getEtag();
  58. }
  59. public function getSize($includeMounts = true) {
  60. return $this->fileInfo->getSize($includeMounts);
  61. }
  62. public function getMtime() {
  63. return $this->fileInfo->getMtime();
  64. }
  65. public function getName() {
  66. return $this->fileInfo->getName();
  67. }
  68. public function getInternalPath() {
  69. return $this->fileInfo->getInternalPath();
  70. }
  71. public function getPath() {
  72. return $this->fileInfo->getPath();
  73. }
  74. public function getMimetype() {
  75. return $this->fileInfo->getMimetype();
  76. }
  77. public function getMimePart() {
  78. return $this->fileInfo->getMimePart();
  79. }
  80. public function getStorage() {
  81. return $this->fileInfo->getStorage();
  82. }
  83. public function getId() {
  84. return $this->fileInfo->getId();
  85. }
  86. public function isEncrypted() {
  87. return $this->fileInfo->isEncrypted();
  88. }
  89. public function getPermissions() {
  90. return $this->fileInfo->getPermissions();
  91. }
  92. public function getType() {
  93. return $this->fileInfo->getType();
  94. }
  95. public function isReadable() {
  96. return $this->fileInfo->isReadable();
  97. }
  98. public function isUpdateable() {
  99. return $this->fileInfo->isUpdateable();
  100. }
  101. public function isCreatable() {
  102. return $this->fileInfo->isCreatable();
  103. }
  104. public function isDeletable() {
  105. return $this->fileInfo->isDeletable();
  106. }
  107. public function isShareable() {
  108. return $this->fileInfo->isShareable();
  109. }
  110. public function isShared() {
  111. return $this->fileInfo->isShared();
  112. }
  113. public function isMounted() {
  114. return $this->fileInfo->isMounted();
  115. }
  116. public function getMountPoint() {
  117. return $this->fileInfo->getMountPoint();
  118. }
  119. public function getOwner() {
  120. return $this->fileInfo->getOwner();
  121. }
  122. public function getChecksum() {
  123. return $this->fileInfo->getChecksum();
  124. }
  125. public function getExtension(): string {
  126. return $this->fileInfo->getExtension();
  127. }
  128. public function getTitle(): string {
  129. return $this->getOriginalLocation();
  130. }
  131. public function getCreationTime(): int {
  132. return $this->fileInfo->getCreationTime();
  133. }
  134. public function getUploadTime(): int {
  135. return $this->fileInfo->getUploadTime();
  136. }
  137. public function getParentId(): int {
  138. return $this->fileInfo->getParentId();
  139. }
  140. public function getDeletedBy(): ?IUser {
  141. return $this->deletedBy;
  142. }
  143. /**
  144. * @inheritDoc
  145. * @return array<string, int|string|bool|float|string[]|int[]>
  146. */
  147. public function getMetadata(): array {
  148. return $this->fileInfo->getMetadata();
  149. }
  150. }