protected function SortNormalizer::expand in JSON:API 8
1 call to SortNormalizer::expand()
- SortNormalizer::denormalize in src/
Normalizer/ SortNormalizer.php - Denormalizes data back into an object of the given class.
File
- src/
Normalizer/ SortNormalizer.php, line 64
Class
- SortNormalizer
- The normalizer used for JSON API sorts.
Namespace
Drupal\jsonapi\NormalizerCode
protected function expand($sort) {
if (empty($sort)) {
throw new BadRequestHttpException('You need to provide a value for the sort parameter.');
}
// Expand a JSON API compliant sort into a more expressive sort parameter.
if (is_string($sort)) {
$sort = $this
->expandFieldString($sort);
}
// Expand any defaults into the sort array.
$expanded = [];
foreach ($sort as $sort_index => $sort_item) {
$expanded[$sort_index] = $this
->expandItem($sort_index, $sort_item);
}
return $expanded;
}