function Drupal::config

Same name and namespace in other branches
  1. 11.x core/lib/Drupal.php \Drupal::config()
  2. 10 core/lib/Drupal.php \Drupal::config()
  3. 9 core/lib/Drupal.php \Drupal::config()
  4. 8.9.x core/lib/Drupal.php \Drupal::config()

Retrieves a configuration object.

This is the main entry point to the configuration API. Calling \Drupal::config('my_module.admin') will return a configuration object the my_module module can use to read its administrative settings.

Parameters

string $name: The name of the configuration object to retrieve, which typically corresponds to a configuration file. For \Drupal::config('my_module.admin'), the configuration object returned will contain the content of the my_module.admin configuration file.

Return value

\Drupal\Core\Config\ImmutableConfig An immutable configuration object.

37 calls to Drupal::config()
AccountForm::form in core/modules/user/src/AccountForm.php
ConfigInstallWebTest::testIntegrationModuleReinstallation in core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
Tests module re-installation.
ConfigLanguageOverrideTest::testConfigLanguageOverride in core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php
Tests locale override based on language.
ConfigOverrideTest::testConfOverride in core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php
Tests configuration override.
DrupalTest::testConfig in core/tests/Drupal/Tests/Core/DrupalTest.php
Tests the config() method.

... See full list

File

core/lib/Drupal.php, line 422

Class

Drupal
Static Service Container wrapper.

Code

public static function config($name) {
  return static::getContainer()->get('config.factory')
    ->get($name);
}

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