Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::getInstance()
  2. 9 core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::getInstance()

Returns the settings instance.

A singleton is used because this class is used before the container is available.

Return value

\Drupal\Core\Site\Settings

Throws

\BadMethodCallException Thrown when the settings instance has not been initialized yet.

5 calls to Settings::getInstance()
ConfigEntityUpdaterTest::testUpdate in core/tests/Drupal/KernelTests/Core/Config/Entity/ConfigEntityUpdaterTest.php
@covers ::update
ConfigEntityUpdaterTest::testUpdateDefaultCallback in core/tests/Drupal/KernelTests/Core/Config/Entity/ConfigEntityUpdaterTest.php
@covers ::update
FileStorageFactoryTest::testGetSync in core/tests/Drupal/KernelTests/Core/Config/FileStorageFactoryTest.php
@covers ::getSync
ForumIndexUpdateTest::testUpdatePath in core/modules/forum/tests/src/Functional/ForumIndexUpdateTest.php
Tests the update path to add the new primary key.
UpdateKernel::handle in core/lib/Drupal/Core/Update/UpdateKernel.php
1 string reference to 'Settings::getInstance'
core.services.yml in core/core.services.yml
core/core.services.yml

File

core/lib/Drupal/Core/Site/Settings.php, line 73

Class

Settings
Read only settings that are initialized with the class.

Namespace

Drupal\Core\Site

Code

public static function getInstance() {
  if (self::$instance === NULL) {
    throw new \BadMethodCallException('Settings::$instance is not initialized yet. Whatever you are trying to do, it might be too early for that. You could call Settings::initialize(), but it is probably better to wait until it is called in the regular way. Also check for recursions.');
  }
  return self::$instance;
}