function Drupal::hasRequest

Same name in other branches
  1. 9 core/lib/Drupal.php \Drupal::hasRequest()
  2. 8.9.x core/lib/Drupal.php \Drupal::hasRequest()
  3. 11.x core/lib/Drupal.php \Drupal::hasRequest()

Indicates if there is a currently active request object.

Return value

bool TRUE if there is a currently active request object, FALSE otherwise.

2 calls to Drupal::hasRequest()
ThemeRegistry::__construct in core/lib/Drupal/Core/Utility/ThemeRegistry.php
Constructs a ThemeRegistry object.
_drupal_log_error in core/includes/errors.inc
Logs a PHP error or exception and displays an error page in fatal cases.

File

core/lib/Drupal.php, line 241

Class

Drupal
Static Service Container wrapper.

Code

public static function hasRequest() {
    // Check hasContainer() first in order to always return a Boolean.
    return static::hasContainer() && static::getContainer()->has('request_stack') && static::getContainer()->get('request_stack')
        ->getCurrentRequest() !== NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.