2018-06-28 08:53:44 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
2024-05-27 11:39:07 -04:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-06-28 08:53:44 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\DAV\Files;
|
|
|
|
|
|
|
|
|
|
use SearchDAV\Backend\ISearchBackend;
|
|
|
|
|
use SearchDAV\Query\Query;
|
|
|
|
|
|
|
|
|
|
class LazySearchBackend implements ISearchBackend {
|
|
|
|
|
/**
|
|
|
|
|
* @var ISearchBackend $backend
|
|
|
|
|
*/
|
|
|
|
|
private $backend = null;
|
|
|
|
|
|
|
|
|
|
public function setBackend(ISearchBackend $backend) {
|
|
|
|
|
$this->backend = $backend;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 17:15:00 -04:00
|
|
|
public function getArbiterPath(): string {
|
2018-06-28 08:53:44 -04:00
|
|
|
if ($this->backend) {
|
|
|
|
|
return $this->backend->getArbiterPath();
|
|
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 17:15:00 -04:00
|
|
|
public function isValidScope(string $href, $depth, ?string $path): bool {
|
2018-06-28 08:53:44 -04:00
|
|
|
if ($this->backend) {
|
|
|
|
|
return $this->backend->getArbiterPath();
|
|
|
|
|
}
|
2022-04-04 17:15:00 -04:00
|
|
|
return false;
|
2018-06-28 08:53:44 -04:00
|
|
|
}
|
|
|
|
|
|
2022-04-04 17:15:00 -04:00
|
|
|
public function getPropertyDefinitionsForScope(string $href, ?String $path): array {
|
2018-06-28 08:53:44 -04:00
|
|
|
if ($this->backend) {
|
2018-07-02 07:42:41 -04:00
|
|
|
return $this->backend->getPropertyDefinitionsForScope($href, $path);
|
2018-06-28 08:53:44 -04:00
|
|
|
}
|
2022-04-04 17:15:00 -04:00
|
|
|
return [];
|
2018-06-28 08:53:44 -04:00
|
|
|
}
|
|
|
|
|
|
2022-04-04 17:15:00 -04:00
|
|
|
public function search(Query $query): array {
|
2018-06-28 08:53:44 -04:00
|
|
|
if ($this->backend) {
|
2018-07-02 07:42:41 -04:00
|
|
|
return $this->backend->search($query);
|
2022-04-04 17:15:00 -04:00
|
|
|
}
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function preloadPropertyFor(array $nodes, array $requestProperties): void {
|
|
|
|
|
if ($this->backend) {
|
|
|
|
|
$this->backend->preloadPropertyFor($nodes, $requestProperties);
|
2018-06-28 08:53:44 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|