You are here

public static function Settings::getInstance in Drupal 8

Same name and namespace in other branches
  1. 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.

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 51

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