RestoreTarget.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\CalDAV\Trashbin;
  8. use OCA\DAV\CalDAV\IRestorable;
  9. use Sabre\DAV\Exception\Forbidden;
  10. use Sabre\DAV\Exception\NotFound;
  11. use Sabre\DAV\ICollection;
  12. use Sabre\DAV\IMoveTarget;
  13. use Sabre\DAV\INode;
  14. class RestoreTarget implements ICollection, IMoveTarget {
  15. public const NAME = 'restore';
  16. public function createFile($name, $data = null) {
  17. throw new Forbidden();
  18. }
  19. public function createDirectory($name) {
  20. throw new Forbidden();
  21. }
  22. public function getChild($name) {
  23. throw new NotFound();
  24. }
  25. public function getChildren(): array {
  26. return [];
  27. }
  28. public function childExists($name): bool {
  29. return false;
  30. }
  31. public function moveInto($targetName, $sourcePath, INode $sourceNode): bool {
  32. if ($sourceNode instanceof IRestorable) {
  33. $sourceNode->restore();
  34. return true;
  35. }
  36. return false;
  37. }
  38. public function delete() {
  39. throw new Forbidden();
  40. }
  41. public function getName(): string {
  42. return 'restore';
  43. }
  44. public function setName($name) {
  45. throw new Forbidden();
  46. }
  47. public function getLastModified() {
  48. return 0;
  49. }
  50. }