You are here

protected function RestfulBase::parseRequestForListPagination in RESTful 7

Parses the request object to get the pagination options.

Return value

array A numeric array with the offset and length options.

Throws

\RestfulBadRequestException

3 calls to RestfulBase::parseRequestForListPagination()
RestfulDataProviderDbQuery::queryForListPagination in plugins/restful/RestfulDataProviderDbQuery.php
Set correct page (i.e. range) for the query for list.
RestfulDataProviderEFQ::queryForListPagination in plugins/restful/RestfulDataProviderEFQ.php
Set correct page (i.e. range) for the query for list.
RestfulDataProviderVariable::applyListPagination in plugins/restful/RestfulDataProviderVariable.php
Set correct page for the index within the array of variables.

File

plugins/restful/RestfulBase.php, line 950
Contains RestfulBase.

Class

RestfulBase
Class \RestfulBase

Code

protected function parseRequestForListPagination() {
  $request = $this
    ->getRequest();
  $page = isset($request['page']) ? $request['page'] : 1;
  if (!ctype_digit((string) $page) || $page < 1) {
    throw new \RestfulBadRequestException('"Page" property should be numeric and equal or higher than 1.');
  }
  $range = $this
    ->getRange();
  $offset = ($page - 1) * $range;
  return array(
    $offset,
    $range,
  );
}