You are here

public function Request::getPagerInput in RESTful 7.2

Get the normalized pager input.

This is to support page=1&range=6 and page[number]=1&page[size]=6 at the same time.

Return value

array An associative array with the pager information in the form of page[number]=1&page[size]=6.

Overrides RequestInterface::getPagerInput

File

src/Http/Request.php, line 263
Contains \Drupal\restful\Http\Request

Class

Request
Deals with everything coming from the consumer.

Namespace

Drupal\restful\Http

Code

public function getPagerInput() {
  $input = $this
    ->getParsedInput();
  if (!isset($input['page'])) {
    $page = array(
      'number' => 1,
    );
  }
  else {
    $page = $input['page'];
    if (!is_array($page)) {
      $page = array(
        'number' => $page,
      );
    }
  }
  if (isset($input['range'])) {
    $page['size'] = $input['range'];
  }
  return $page + array(
    'number' => 1,
  );
}