You are here

public static function Request::createFromGlobals in RESTful 7.2

Creates a new request with values from PHP's super globals.

Return value

RequestInterface Request A Request instance

Overrides RequestInterface::createFromGlobals

1 call to Request::createFromGlobals()
RestfulManager::createFromGlobals in src/RestfulManager.php
Factory method.

File

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

Class

Request
Deals with everything coming from the consumer.

Namespace

Drupal\restful\Http

Code

public static function createFromGlobals() {
  $path = implode('/', arg());
  $query = drupal_get_query_parameters();
  $method = strtoupper($_SERVER['REQUEST_METHOD']);

  // This flag is used to identify if the request is done "via Drupal" or "via
  // CURL";
  $via_router = TRUE;
  $headers = static::parseHeadersFromGlobals();
  $csrf_token = $headers
    ->get('x-csrf-token')
    ->getValueString();
  return static::create($path, $query, $method, $headers, $via_router, $csrf_token, $_COOKIE, $_FILES, $_SERVER);
}