diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 25773bf..13f7107 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -10,7 +10,6 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; -use Drupal\Core\DependencyInjection\ContainerNotInitializedException; use Drupal\Core\DrupalKernel; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Logger\RfcLogLevel; diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 9c50eb1..1bc06ea 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -120,8 +120,10 @@ public static function unsetContainer() { /** * Returns the currently active global container. * - * @deprecated This method is only useful for the testing environment. It - * should not be used otherwise. + * @deprecated This method currently returns NULL when the container is not + * initialized. This behavior is deprecated, before 8.0.0 it will instead + * throw an exception. An additional parameter was added to simulate the + * future behavior. * * @throws \Drupal\Core\DependencyInjection\ContainerNotInitializedException * @@ -174,6 +176,7 @@ public static function service($id) { * TRUE if the specified service exists, FALSE otherwise. */ public static function hasService($id) { + // Check hasContainer() first in order to always return a Boolean. return static::hasContainer() && static::getContainer()->has($id); } @@ -193,6 +196,7 @@ public static function root() { * TRUE if there is a currently active request object, FALSE otherwise. */ 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; }