RestoreFolder.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 Sabre\DAV\Exception\Forbidden;
  9. use Sabre\DAV\ICollection;
  10. use Sabre\DAV\IMoveTarget;
  11. use Sabre\DAV\INode;
  12. class RestoreFolder implements ICollection, IMoveTarget {
  13. public function createFile($name, $data = null) {
  14. throw new Forbidden();
  15. }
  16. public function createDirectory($name) {
  17. throw new Forbidden();
  18. }
  19. public function getChild($name) {
  20. return null;
  21. }
  22. public function delete() {
  23. throw new Forbidden();
  24. }
  25. public function getName() {
  26. return 'restore';
  27. }
  28. public function setName($name) {
  29. throw new Forbidden();
  30. }
  31. public function getLastModified(): int {
  32. return 0;
  33. }
  34. public function getChildren(): array {
  35. return [];
  36. }
  37. public function childExists($name): bool {
  38. return false;
  39. }
  40. public function moveInto($targetName, $sourcePath, INode $sourceNode): bool {
  41. if (!($sourceNode instanceof ITrash)) {
  42. return false;
  43. }
  44. return $sourceNode->restore();
  45. }
  46. }