You are here

protected function RestfulBase::overrideRange in RESTful 7

Overrides the range parameter with the URL value if any.

Throws

RestfulBadRequestException

1 call to RestfulBase::overrideRange()
RestfulBase::process in plugins/restful/RestfulBase.php
Entry point to process a request.

File

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

Class

RestfulBase
Class \RestfulBase

Code

protected function overrideRange() {
  $request = $this
    ->getRequest();
  if (!empty($request['range'])) {
    $url_params = $this
      ->getPluginKey('url_params');
    if (!$url_params['range']) {
      throw new \RestfulBadRequestException('The range parameter has been disabled in server configuration.');
    }
    if (!ctype_digit((string) $request['range']) || $request['range'] < 1) {
      throw new \RestfulBadRequestException('"Range" property should be numeric and higher than 0.');
    }
    if ($request['range'] < $this
      ->getRange()) {

      // If there is a valid range property in the request override the range.
      $this
        ->setRange($request['range']);
    }
  }
}