Skip to content
Snippets Groups Projects
Commit 92fddf5b authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

unify checking methods, fixes #2815

Closes #2815

Merge request studip/studip!1897
parent f88e5ece
No related branches found
No related tags found
No related merge requests found
Pipeline #13620 passed
......@@ -104,16 +104,15 @@ class QueryChecker
protected function checkSorting(ErrorCollection $errors, QueryParserInterface $queryParser): void
{
$sorts = iterator_to_array($queryParser->getSorts());
if (null !== $sorts && null !== $this->sortParameters) {
foreach (array_keys($sorts) as $sortParameter) {
if (!array_key_exists($sortParameter, $this->sortParameters)) {
$errors->addQueryParameterError(
QueryParser::PARAM_SORT,
sprintf('Sort parameter %s is not allowed.', $sortParameter)
);
}
}
$withinAllowed = $this->keysWithinAllowed(
iterator_to_array($queryParser->getSorts()),
$this->sortParameters
);
if (!$withinAllowed) {
$errors->addQueryParameterError(
QueryParser::PARAM_SORT,
'Sort parameter should contain only allowed values.'
);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment