You are here

public static function Request::create in RESTful 7.2

Creates a Request based on a given URI and configuration.

Parameters

string $path: The requested path.

array $query: The query string parameters being passed.

string $method: A valid HTTP method

HttpHeaderBag $headers: The headers for the request

bool $via_router: Boolean indicating that if the requested was created via the Drupal's menu router.

string $csrf_token: A CSRF token that applies to the current request.

array $cookies: An array of key value pairs containing information about the cookies.

array $files: An array of key value pairs containing information about the files.

array $server: An array of key value pairs containing information about the server.

Return value

RequestInterface Request A Request instance

Overrides RequestInterface::create

52 calls to Request::create()
DataProviderResource::init in src/Plugin/resource/DataProvider/DataProviderResource.php
Creates a new DataProviderResource object from the resource info.
FormatterJsonApi::populateCachePlaceholder in src/Plugin/formatter/FormatterJsonApi.php
Given a field item that contains a cache placeholder render and cache it.
Request::createFromGlobals in src/Http/Request.php
Creates a new request with values from PHP's super globals.
Resource::doDelete in src/Plugin/resource/Resource.php
Shorthand method to perform a quick DELETE request.
Resource::doGet in src/Plugin/resource/Resource.php
Shorthand method to perform a quick GET request.

... See full list

File

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

Class

Request
Deals with everything coming from the consumer.

Namespace

Drupal\restful\Http

Code

public static function create($path, array $query = array(), $method = 'GET', HttpHeaderBag $headers = NULL, $via_router = FALSE, $csrf_token = NULL, array $cookies = array(), array $files = array(), array $server = array(), $parsed_body = NULL) {
  if (!$headers) {
    $headers = new HttpHeaderBag();
  }
  if (($overridden_method = strtoupper($headers
    ->get('x-http-method-override')
    ->getValueString())) && $method == static::METHOD_POST) {
    if (!static::isValidMethod($overridden_method)) {
      throw new BadRequestException(sprintf('Invalid overridden method: %s.', $overridden_method));
    }
    $method = $overridden_method;
  }
  return new static($path, $query, $method, $headers, $via_router, $csrf_token, $cookies, $files, $server, $parsed_body);
}