LazySearchBackend.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\DAV\Files;
  7. use SearchDAV\Backend\ISearchBackend;
  8. use SearchDAV\Query\Query;
  9. class LazySearchBackend implements ISearchBackend {
  10. /**
  11. * @var ISearchBackend $backend
  12. */
  13. private $backend = null;
  14. public function setBackend(ISearchBackend $backend) {
  15. $this->backend = $backend;
  16. }
  17. public function getArbiterPath(): string {
  18. if ($this->backend) {
  19. return $this->backend->getArbiterPath();
  20. } else {
  21. return '';
  22. }
  23. }
  24. public function isValidScope(string $href, $depth, ?string $path): bool {
  25. if ($this->backend) {
  26. return $this->backend->getArbiterPath();
  27. }
  28. return false;
  29. }
  30. public function getPropertyDefinitionsForScope(string $href, ?String $path): array {
  31. if ($this->backend) {
  32. return $this->backend->getPropertyDefinitionsForScope($href, $path);
  33. }
  34. return [];
  35. }
  36. public function search(Query $query): array {
  37. if ($this->backend) {
  38. return $this->backend->search($query);
  39. }
  40. return [];
  41. }
  42. public function preloadPropertyFor(array $nodes, array $requestProperties): void {
  43. if ($this->backend) {
  44. $this->backend->preloadPropertyFor($nodes, $requestProperties);
  45. }
  46. }
  47. }