RestoreFolder.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_Versions\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 VersionFile)) {
  42. return false;
  43. }
  44. $sourceNode->rollBack();
  45. return true;
  46. }
  47. }