function Drupal::setContainer

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

Sets a new global container.

Parameters

\Symfony\Component\DependencyInjection\ContainerInterface $container: A new container instance to replace the current.

217 calls to Drupal::setContainer()
AccessManagerTest::setUp in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
AccessPolicyProcessorTest::setUp in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php
AccessResultTest::setUp in core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
ActiveWorkspaceCheckTest::setUp in core/modules/workspaces/tests/src/Unit/ActiveWorkspaceCheckTest.php
BaseFieldDefinitionTest::setUp in core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php

... See full list

File

core/lib/Drupal.php, line 149

Class

Drupal
Static Service Container wrapper.

Code

public static function setContainer(ContainerInterface $container) {
    static::$container = $container;
}

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