function EntityResource::getJsonApiParams
Same name in other branches
- 9 core/modules/jsonapi/src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::getJsonApiParams()
- 10 core/modules/jsonapi/src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::getJsonApiParams()
- 11.x core/modules/jsonapi/src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::getJsonApiParams()
Extracts JSON:API query parameters from the request.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request object.
\Drupal\jsonapi\ResourceType\ResourceType $resource_type: The JSON:API resource type.
Return value
array An array of JSON:API parameters like `sort` and `filter`.
1 call to EntityResource::getJsonApiParams()
- EntityResource::getCollection in core/
modules/ jsonapi/ src/ Controller/ EntityResource.php - Gets the collection of entities.
File
-
core/
modules/ jsonapi/ src/ Controller/ EntityResource.php, line 1209
Class
- EntityResource
- Process all entity requests.
Namespace
Drupal\jsonapi\ControllerCode
protected function getJsonApiParams(Request $request, ResourceType $resource_type) {
if ($request->query
->has('filter')) {
$params[Filter::KEY_NAME] = Filter::createFromQueryParameter($request->query
->get('filter'), $resource_type, $this->fieldResolver);
}
if ($request->query
->has('sort')) {
$params[Sort::KEY_NAME] = Sort::createFromQueryParameter($request->query
->get('sort'));
}
if ($request->query
->has('page')) {
$params[OffsetPage::KEY_NAME] = OffsetPage::createFromQueryParameter($request->query
->get('page'));
}
else {
$params[OffsetPage::KEY_NAME] = OffsetPage::createFromQueryParameter([
'page' => [
'offset' => OffsetPage::DEFAULT_OFFSET,
'limit' => OffsetPage::SIZE_MAX,
],
]);
}
return $params;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.