Drupal::hasRequest

public static 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.

File

core/lib/Drupal.php, line 190
Contains \Drupal.

Class

Drupal
Static Service Container wrapper.

Code

1
2
3
4
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;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.