function Settings::getInstance

Same name in other branches
  1. 9 core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::getInstance()
  2. 8.9.x core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::getInstance()
  3. 10 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.

9 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.
install_begin_request in core/includes/install.core.inc
Begins an installation request, modifying the installation state as needed.

... See full list

File

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

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;
}

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