public static function Drupal::request

Retrieves the currently active request object.

Note: The use of this wrapper in particular is especially discouraged. Most code should not need to access the request directly. Doing so means it will only function when handling an HTTP request, and will require special modification or wrapping when run from a command line tool, from certain queue processors, or from automated tests.

If code must access the request, it is considerably better to register an object with the Service Container and give it a setRequest() method that is configured to run when the service is created. That way, the correct request object can always be provided by the container and the service can still be unit tested.

If this method must be used, never save the request object that is returned. Doing so may lead to inconsistencies as the request object is volatile and may change at various times, such as during a subrequest.

Return value

\Symfony\Component\HttpFoundation\Request The currently active request object.

4 calls to Drupal::request()
CachePluginBase::generateResultsKey in drupal/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
Calculates and sets a cache ID used for the result cache.
drupal_redirect_form in drupal/core/includes/form.inc
Redirects the user to a URL after a form has been processed.
image_style_url in drupal/core/modules/image/image.module
Returns the URL for an image derivative given a style and image path.
_toolbar_initialize_page_cache in drupal/core/modules/toolbar/toolbar.module
Use Drupal's page cache for toolbar/subtrees/*, even for authenticated users.

File

drupal/core/lib/Drupal.php, line 146
Contains Drupal.

Class

Drupal
Static Service Container wrapper.

Code

public static function request() {
  return static::$container
    ->get('request');
}