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 ...@@ -104,16 +104,15 @@ class QueryChecker
protected function checkSorting(ErrorCollection $errors, QueryParserInterface $queryParser): void protected function checkSorting(ErrorCollection $errors, QueryParserInterface $queryParser): void
{ {
$sorts = iterator_to_array($queryParser->getSorts()); $withinAllowed = $this->keysWithinAllowed(
if (null !== $sorts && null !== $this->sortParameters) { iterator_to_array($queryParser->getSorts()),
foreach (array_keys($sorts) as $sortParameter) { $this->sortParameters
if (!array_key_exists($sortParameter, $this->sortParameters)) { );
$errors->addQueryParameterError( if (!$withinAllowed) {
QueryParser::PARAM_SORT, $errors->addQueryParameterError(
sprintf('Sort parameter %s is not allowed.', $sortParameter) 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