You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractTrash.php 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace OCA\Files_Trashbin\Sabre;
  23. use OCA\Files_Trashbin\Trash\ITrashItem;
  24. use OCA\Files_Trashbin\Trash\ITrashManager;
  25. use OCP\Files\FileInfo;
  26. use OCP\IUser;
  27. abstract class AbstractTrash implements ITrash {
  28. /** @var ITrashItem */
  29. protected $data;
  30. /** @var ITrashManager */
  31. protected $trashManager;
  32. public function __construct(ITrashManager $trashManager, ITrashItem $data) {
  33. $this->trashManager = $trashManager;
  34. $this->data = $data;
  35. }
  36. public function getFilename(): string {
  37. return $this->data->getName();
  38. }
  39. public function getDeletionTime(): int {
  40. return $this->data->getDeletedTime();
  41. }
  42. public function getFileId(): int {
  43. return $this->data->getId();
  44. }
  45. public function getFileInfo(): FileInfo {
  46. return $this->data;
  47. }
  48. public function getSize(): int {
  49. return $this->data->getSize();
  50. }
  51. public function getLastModified(): int {
  52. return $this->data->getMtime();
  53. }
  54. public function getContentType(): string {
  55. return $this->data->getMimetype();
  56. }
  57. public function getETag(): string {
  58. return $this->data->getEtag();
  59. }
  60. public function getName(): string {
  61. return $this->data->getName();
  62. }
  63. public function getOriginalLocation(): string {
  64. return $this->data->getOriginalLocation();
  65. }
  66. public function getTitle(): string {
  67. return $this->data->getTitle();
  68. }
  69. public function delete() {
  70. $this->trashManager->removeItem($this->data);
  71. }
  72. public function restore(): bool {
  73. $this->trashManager->restoreItem($this->data);
  74. return true;
  75. }
  76. }