You are here

public static function Request::createFromGlobals in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Request.php \Symfony\Component\HttpFoundation\Request::createFromGlobals()

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

Return value

Request A new request

39 calls to Request::createFromGlobals()
authorize.php in core/authorize.php
Administrative script for running authorized file operations.
BrowserTestBase::prepareEnvironment in core/modules/simpletest/src/BrowserTestBase.php
Prepares the current environment for running the test.
BrowserTestBase::prepareRequestForGenerator in core/modules/simpletest/src/BrowserTestBase.php
Creates a mock request and sets it on the generator.
DateTest::testFormatTimeDiffSince in core/tests/Drupal/Tests/Core/Datetime/DateTest.php
Tests the formatTimeDiffSince method.
DateTest::testFormatTimeDiffUntil in core/tests/Drupal/Tests/Core/Datetime/DateTest.php
Tests the formatTimeDiffUntil method.

... See full list

File

vendor/symfony/http-foundation/Request.php, line 265

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public static function createFromGlobals() {

  // With the php's bug #66606, the php's built-in web server
  // stores the Content-Type and Content-Length header values in
  // HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields.
  $server = $_SERVER;
  if ('cli-server' === php_sapi_name()) {
    if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) {
      $server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH'];
    }
    if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
      $server['CONTENT_TYPE'] = $_SERVER['HTTP_CONTENT_TYPE'];
    }
  }
  $request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $server);
  if (0 === strpos($request->headers
    ->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') && in_array(strtoupper($request->server
    ->get('REQUEST_METHOD', 'GET')), array(
    'PUT',
    'DELETE',
    'PATCH',
  ))) {
    parse_str($request
      ->getContent(), $data);
    $request->request = new ParameterBag($data);
  }
  return $request;
}