1
0

AbstractTrash.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files_Trashbin\Sabre;
  8. use OCA\Files_Trashbin\Trash\ITrashItem;
  9. use OCA\Files_Trashbin\Trash\ITrashManager;
  10. use OCP\Files\FileInfo;
  11. use OCP\IUser;
  12. abstract class AbstractTrash implements ITrash {
  13. public function __construct(
  14. protected ITrashManager $trashManager,
  15. protected ITrashItem $data,
  16. ) {
  17. }
  18. public function getFilename(): string {
  19. return $this->data->getName();
  20. }
  21. public function getDeletionTime(): int {
  22. return $this->data->getDeletedTime();
  23. }
  24. public function getFileId(): int {
  25. return $this->data->getId();
  26. }
  27. public function getFileInfo(): FileInfo {
  28. return $this->data;
  29. }
  30. /**
  31. * @psalm-suppress ImplementedReturnTypeMismatch \Sabre\DAV\IFile::getSize signature does not support 32bit
  32. * @return int|float
  33. */
  34. public function getSize(): int|float {
  35. return $this->data->getSize();
  36. }
  37. public function getLastModified(): int {
  38. return $this->data->getMtime();
  39. }
  40. public function getContentType(): string {
  41. return $this->data->getMimetype();
  42. }
  43. public function getETag(): string {
  44. return $this->data->getEtag();
  45. }
  46. public function getName(): string {
  47. return $this->data->getName();
  48. }
  49. public function getOriginalLocation(): string {
  50. return $this->data->getOriginalLocation();
  51. }
  52. public function getTitle(): string {
  53. return $this->data->getTitle();
  54. }
  55. public function getDeletedBy(): ?IUser {
  56. return $this->data->getDeletedBy();
  57. }
  58. public function delete() {
  59. $this->trashManager->removeItem($this->data);
  60. }
  61. public function restore(): bool {
  62. $this->trashManager->restoreItem($this->data);
  63. return true;
  64. }
  65. }