function Settings::getInstance

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

8 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
DatabaseBackendFactory::__construct in core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php
Constructs the DatabaseBackendFactory object.
FileStorageFactoryTest::testGetSync in core/tests/Drupal/KernelTests/Core/Config/FileStorageFactoryTest.php
@covers ::getSync
install_begin_request in core/includes/install.core.inc
Begins an installation request, modifying the installation state as needed.

... See full list

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 85

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.