You are here

public static function Drupal::hasRequest in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal.php \Drupal::hasRequest()
  2. 10 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 240

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;
}