This commit is contained in:
Robin Appelman 2019-11-06 14:15:26 +01:00
commit 7174c02348
2 changed files with 77 additions and 58 deletions

View file

@ -84,7 +84,8 @@ class SearchHandler {
$response->setBody($e->getMessage());
return false;
}
$data = $this->server->generateMultiStatus(iterator_to_array($this->getPropertiesIteratorResults($results, $query->select)), false);
$data = $this->server->generateMultiStatus(iterator_to_array($this->getPropertiesIteratorResults($results,
$query->select)), false);
$response->setBody($data);
return false;
}
@ -96,7 +97,7 @@ class SearchHandler {
* @throws BadRequest
*/
private function getQueryForXML(BasicSearch $xml, array $allProps) {
$orderBy = array_map(function(\SearchDAV\XML\Order $order) use ($allProps) {
$orderBy = array_map(function (\SearchDAV\XML\Order $order) use ($allProps) {
if (!isset($allProps[$order->property])) {
throw new BadRequest('requested order by property is not a valid property for this scope');
}
@ -106,7 +107,7 @@ class SearchHandler {
}
return new Order($prop, $order->order);
}, $xml->orderBy);
$select = array_map(function($propName) use ($allProps) {
$select = array_map(function ($propName) use ($allProps) {
if (!isset($allProps[$propName])) {
return;
}
@ -130,7 +131,7 @@ class SearchHandler {
* @throws BadRequest
*/
private function transformOperator(\SearchDAV\XML\Operator $operator, array $allProps) {
$arguments = array_map(function($argument) use ($allProps) {
$arguments = array_map(function ($argument) use ($allProps) {
if (is_string($argument)) {
if (!isset($allProps[$argument])) {
throw new BadRequest('requested search property is not a valid property for this scope');
@ -140,10 +141,12 @@ class SearchHandler {
throw new BadRequest('requested search property is not searchable');
}
return $prop;
} else if ($argument instanceof \SearchDAV\XML\Operator) {
return $this->transformOperator($argument, $allProps);
} else {
return $argument;
if ($argument instanceof \SearchDAV\XML\Operator) {
return $this->transformOperator($argument, $allProps);
} else {
return $argument;
}
}
}, $operator->arguments);