protected function DataProvider::parseRequestForListPagination in RESTful 7.2
Parses the request object to get the pagination options.
Return value
array A numeric array with the offset and length options.
Throws
2 calls to DataProvider::parseRequestForListPagination()
- DataProviderDbQuery::queryForListPagination in src/
Plugin/ resource/ DataProvider/ DataProviderDbQuery.php - Set correct page (i.e. range) for the query for list.
- DataProviderEntity::queryForListPagination in src/
Plugin/ resource/ DataProvider/ DataProviderEntity.php - Set correct page (i.e. range) for the query for list.
File
- src/
Plugin/ resource/ DataProvider/ DataProvider.php, line 418 - Contains \Drupal\restful\Plugin\resource\DataProvider\DataProvider.
Class
Namespace
Drupal\restful\Plugin\resource\DataProviderCode
protected function parseRequestForListPagination() {
$pager_input = $this
->getRequest()
->getPagerInput();
$page = isset($pager_input['number']) ? $pager_input['number'] : 1;
if (!ctype_digit((string) $page) || $page < 1) {
throw new BadRequestException('"Page" property should be numeric and equal or higher than 1.');
}
$range = isset($pager_input['size']) ? (int) $pager_input['size'] : $this
->getRange();
$range = $range > $this
->getRange() ? $this
->getRange() : $range;
if (!ctype_digit((string) $range) || $range < 1) {
throw new BadRequestException('"Range" property should be numeric and equal or higher than 1.');
}
$url_params = empty($this->options['urlParams']) ? array() : $this->options['urlParams'];
if (isset($url_params['range']) && !$url_params['range']) {
throw new UnprocessableEntityException('Range parameters have been disabled in server configuration.');
}
$offset = ($page - 1) * $range;
return array(
$offset,
$range,
);
}