You are here

public function RestfulBase::process in RESTful 7

Entry point to process a request.

Parameters

string $path: The requested path.

array $request: The request array.

string $method: The HTTP method.

bool $check_rate_limit: Determines if rate limit should be checked. This could be set to FALSE for example when inside a recursion, and we don't want to cout multiple times the same request. Defautls to TRUE.

Return value

mixed The return value can depend on the controller for the current $method.

Overrides RestfulInterface::process

6 calls to RestfulBase::process()
RestfulBase::delete in plugins/restful/RestfulBase.php
Call resource using the DELETE http method.
RestfulBase::get in plugins/restful/RestfulBase.php
Call resource using the GET http method.
RestfulBase::head in plugins/restful/RestfulBase.php
Call resource using the GET http method.
RestfulBase::patch in plugins/restful/RestfulBase.php
Call resource using the PATCH http method.
RestfulBase::post in plugins/restful/RestfulBase.php
Call resource using the POST http method.

... See full list

File

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

Class

RestfulBase
Class \RestfulBase

Code

public function process($path = '', array $request = array(), $method = \RestfulInterface::GET, $check_rate_limit = TRUE) {
  $this
    ->setMethod($method);
  $this
    ->setPath($path);
  $this
    ->setRequest($request);

  // Clear all static caches from previous requests.
  $this->staticCache
    ->clearAll();

  // Override the range with the value in the URL.
  $this
    ->overrideRange();
  $version = $this
    ->getVersion();
  $this
    ->setHttpHeaders('X-API-Version', 'v' . $version['major'] . '.' . $version['minor']);
  if (!($method_name = $this
    ->getControllerFromPath())) {
    throw new RestfulBadRequestException('Path does not exist');
  }
  if ($check_rate_limit && $this
    ->getRateLimitManager()) {

    // This will throw the appropriate exception if needed.
    $this
      ->getRateLimitManager()
      ->checkRateLimit($request);
  }
  $return = $this
    ->{$method_name}($path);
  if (empty($request['__application']['rest_call'])) {

    // Switch back to the original user.
    $this
      ->getAuthenticationManager()
      ->switchUserBack();
  }
  return $return;
}