You are here

protected function EntityResource::setPageLimit in JSON:API Extras 8.3

Sets a jsonapi parameter for the page limit if applicable.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

\Drupal\jsonapi_extras\Entity\JsonapiResourceConfig $resource_config: The resource config entity to check for an override of the page limit.

array $params: The parameters passed to jsonapi, passed by reference.

1 call to EntityResource::setPageLimit()
EntityResource::getJsonApiParams in modules/jsonapi_defaults/src/Controller/EntityResource.php
Extracts JSON:API query parameters from the request.

File

modules/jsonapi_defaults/src/Controller/EntityResource.php, line 228

Class

EntityResource
Overrides jsonapi module EntityResource controller.

Namespace

Drupal\jsonapi_defaults\Controller

Code

protected function setPageLimit(Request $request, JsonapiResourceConfig $resource_config, array &$params) {
  if ($request->query
    ->has('page')) {
    $page_params = $request->query
      ->get('page');
    $offset = array_key_exists(OffsetPage::OFFSET_KEY, $page_params) ? (int) $page_params[OffsetPage::OFFSET_KEY] : OffsetPage::DEFAULT_OFFSET;
    $params[OffsetPage::KEY_NAME] = new OffsetPage($offset, $this
      ->determinePageLimit($page_params, $resource_config));
  }
}