mirror of
https://codeberg.org/icewind/SearchDAV.git
synced 2026-06-03 09:34:08 +02:00
Merge pull request #12 from CarlSchwan/feat/allow-preloading
Allow preloading of properties in one go
This commit is contained in:
commit
7bf414d47a
2 changed files with 12 additions and 0 deletions
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace SearchDAV\Backend;
|
||||
|
||||
use Sabre\DAV\INode;
|
||||
use SearchDAV\Query\Query;
|
||||
|
||||
interface ISearchBackend {
|
||||
|
|
@ -81,4 +82,10 @@ interface ISearchBackend {
|
|||
* @return SearchResult[]
|
||||
*/
|
||||
public function search(Query $query);
|
||||
|
||||
/**
|
||||
* @param INode[] $nodes
|
||||
* @param string[] $requestProperties
|
||||
*/
|
||||
public function preloadPropertyFor(array $nodes, array $requestProperties): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
namespace SearchDAV\DAV;
|
||||
|
||||
use Sabre\DAV\Exception\BadRequest;
|
||||
use Sabre\DAV\INode;
|
||||
use Sabre\DAV\PropFind;
|
||||
use Sabre\DAV\Server;
|
||||
use Sabre\HTTP\ResponseInterface;
|
||||
|
|
@ -170,6 +171,10 @@ class SearchHandler {
|
|||
private function getPropertiesIteratorResults($results, $propertyNames = [], $depth = 0): \Iterator {
|
||||
$propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS;
|
||||
|
||||
$this->searchBackend->preloadPropertyFor(array_map(function (SearchResult $result): INode {
|
||||
return $result->node;
|
||||
}, $results), $propertyNames);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$node = $result->node;
|
||||
$propFind = new PropFind($result->href, (array)$propertyNames, $depth, $propFindType);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue