function Drupal::getContainer
Same name in other branches
- 9 core/lib/Drupal.php \Drupal::getContainer()
- 8.9.x core/lib/Drupal.php \Drupal::getContainer()
- 11.x core/lib/Drupal.php \Drupal::getContainer()
Returns the currently active global container.
Return value
\Drupal\Component\DependencyInjection\ContainerInterface
Throws
\Drupal\Core\DependencyInjection\ContainerNotInitializedException
63 calls to Drupal::getContainer()
- BigPipeTestController::test in core/
modules/ big_pipe/ tests/ modules/ big_pipe_test/ src/ BigPipeTestController.php - Returns all BigPipe placeholder test case render arrays.
- BlockUiTest::testBlockPlacementIndicator in core/
modules/ block/ tests/ src/ Functional/ BlockUiTest.php - Tests the block placement indicator.
- Cache::getBins in core/
lib/ Drupal/ Core/ Cache/ Cache.php - Gets all cache bin services.
- Cache::getMemoryBins in core/
lib/ Drupal/ Core/ Cache/ Cache.php - Gets all memory cache bin services.
- CheckProvider::__construct in core/
lib/ Drupal/ Core/ Access/ CheckProvider.php - Constructs a CheckProvider object.
File
-
core/
lib/ Drupal.php, line 167
Class
- Drupal
- Static Service Container wrapper.
Code
public static function getContainer() {
if (static::$container === NULL) {
throw new ContainerNotInitializedException('\\Drupal::$container is not initialized yet. \\Drupal::setContainer() must be called with a real container.');
}
return static::$container;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.