mirror of
https://codeberg.org/icewind/SearchDAV.git
synced 2026-06-04 10:04:06 +02:00
more types
This commit is contained in:
parent
721b8825d8
commit
d3eb42cd90
14 changed files with 32 additions and 34 deletions
|
|
@ -54,7 +54,7 @@ class DiscoverHandler {
|
|||
$this->queryParser = $queryParser;
|
||||
}
|
||||
|
||||
public function handelDiscoverRequest($xml, RequestInterface $request, ResponseInterface $response) {
|
||||
public function handelDiscoverRequest($xml, RequestInterface $request, ResponseInterface $response): bool {
|
||||
if (!isset($xml['{DAV:}basicsearch'])) {
|
||||
$response->setStatus(400);
|
||||
$response->setBody('Unexpected xml content for query-schema-discovery, expected basicsearch');
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class PathHelper {
|
|||
$this->server = $server;
|
||||
}
|
||||
|
||||
public function getPathFromUri($uri): ?string {
|
||||
public function getPathFromUri(string $uri): ?string {
|
||||
if (strpos($uri, '://') === false) {
|
||||
return $uri;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class SearchHandler {
|
|||
$this->server = $server;
|
||||
}
|
||||
|
||||
public function handleSearchRequest($xml, ResponseInterface $response) {
|
||||
public function handleSearchRequest($xml, ResponseInterface $response): bool {
|
||||
if (!isset($xml['{DAV:}basicsearch'])) {
|
||||
$response->setStatus(400);
|
||||
$response->setBody('Unexpected xml content for searchrequest, expected basicsearch');
|
||||
|
|
@ -129,7 +129,7 @@ class SearchHandler {
|
|||
|
||||
/**
|
||||
* @param \SearchDAV\XML\Operator $operator
|
||||
* @param array $allProps
|
||||
* @param SearchPropertyDefinition[] $allProps
|
||||
* @return Operator
|
||||
* @throws BadRequest
|
||||
*/
|
||||
|
|
@ -166,11 +166,11 @@ class SearchHandler {
|
|||
* If a depth of 1 is requested child elements will also be returned.
|
||||
*
|
||||
* @param SearchResult[] $results
|
||||
* @param array $propertyNames
|
||||
* @param string[] $propertyNames
|
||||
* @param int $depth
|
||||
* @return \Iterator
|
||||
* @return \Iterator<array>
|
||||
*/
|
||||
private function getPropertiesIteratorResults($results, $propertyNames = [], $depth = 0): \Iterator {
|
||||
private function getPropertiesIteratorResults(array $results, array $propertyNames = [], int $depth = 0): \Iterator {
|
||||
$propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS;
|
||||
|
||||
$this->searchBackend->preloadPropertyFor(array_map(function (SearchResult $result): INode {
|
||||
|
|
@ -179,7 +179,7 @@ class SearchHandler {
|
|||
|
||||
foreach ($results as $result) {
|
||||
$node = $result->node;
|
||||
$propFind = new PropFind($result->href, (array)$propertyNames, $depth, $propFindType);
|
||||
$propFind = new PropFind($result->href, $propertyNames, $depth, $propFindType);
|
||||
$r = $this->server->getPropertiesByNode($propFind, $node);
|
||||
if ($r) {
|
||||
$result = $propFind->getResultForMultiStatus();
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class SearchPlugin extends ServerPlugin {
|
|||
$this->queryParser = new QueryParser();
|
||||
}
|
||||
|
||||
public function initialize(Server $server) {
|
||||
public function initialize(Server $server): void {
|
||||
$this->server = $server;
|
||||
$this->pathHelper = new PathHelper($server);
|
||||
$this->search = new SearchHandler($this->searchBackend, $this->pathHelper, $server);
|
||||
|
|
@ -67,7 +67,7 @@ class SearchPlugin extends ServerPlugin {
|
|||
$server->on('propFind', [$this, 'propFindHandler']);
|
||||
}
|
||||
|
||||
public function propFindHandler(PropFind $propFind, INode $node) {
|
||||
public function propFindHandler(PropFind $propFind, INode $node): void {
|
||||
if ($propFind->getPath() === $this->searchBackend->getArbiterPath()) {
|
||||
$propFind->handle('{DAV:}supported-query-grammar-set', new SupportedQueryGrammar());
|
||||
}
|
||||
|
|
@ -77,9 +77,9 @@ class SearchPlugin extends ServerPlugin {
|
|||
* SEARCH is allowed for users files
|
||||
*
|
||||
* @param string $path
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getHTTPMethods($path) {
|
||||
public function getHTTPMethods($path): array {
|
||||
$path = $this->pathHelper->getPathFromUri($path);
|
||||
if ($this->searchBackend->getArbiterPath() === $path) {
|
||||
return ['SEARCH'];
|
||||
|
|
@ -88,13 +88,13 @@ class SearchPlugin extends ServerPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public function optionHandler(RequestInterface $request, ResponseInterface $response) {
|
||||
public function optionHandler(RequestInterface $request, ResponseInterface $response): void {
|
||||
if ($request->getPath() === $this->searchBackend->getArbiterPath()) {
|
||||
$response->addHeader('DASL', '<DAV:basicsearch>');
|
||||
}
|
||||
}
|
||||
|
||||
public function searchHandler(RequestInterface $request, ResponseInterface $response) {
|
||||
public function searchHandler(RequestInterface $request, ResponseInterface $response): bool {
|
||||
$contentType = $request->getHeader('Content-Type') ?? '';
|
||||
|
||||
// Currently, we only support xml search queries
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue