function ConfigFactory::doGet

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Config/ConfigFactory.php \Drupal\Core\Config\ConfigFactory::doGet()
  2. 8.9.x core/lib/Drupal/Core/Config/ConfigFactory.php \Drupal\Core\Config\ConfigFactory::doGet()
  3. 10 core/lib/Drupal/Core/Config/ConfigFactory.php \Drupal\Core\Config\ConfigFactory::doGet()

Returns a configuration object for a given name.

Parameters

string $name: The name of the configuration object to construct.

bool $immutable: (optional) Create an immutable configuration object. Defaults to TRUE.

Return value

\Drupal\Core\Config\Config|\Drupal\Core\Config\ImmutableConfig A configuration object.

2 calls to ConfigFactory::doGet()
ConfigFactory::get in core/lib/Drupal/Core/Config/ConfigFactory.php
Returns an immutable configuration object for a given name.
ConfigFactory::getEditable in core/lib/Drupal/Core/Config/ConfigFactory.php
Returns a mutable configuration object for a given name.

File

core/lib/Drupal/Core/Config/ConfigFactory.php, line 103

Class

ConfigFactory
Defines the configuration object factory.

Namespace

Drupal\Core\Config

Code

protected function doGet($name, $immutable = TRUE) {
    if ($config = $this->doLoadMultiple([
        $name,
    ], $immutable)) {
        return $config[$name];
    }
    else {
        // If the configuration object does not exist in the configuration
        // storage, create a new object.
        $config = $this->createConfigObject($name, $immutable);
        if ($immutable) {
            // Get and apply any overrides.
            $overrides = $this->loadOverrides([
                $name,
            ]);
            if (isset($overrides[$name])) {
                $config->setModuleOverride($overrides[$name]);
            }
            // Apply any settings.php overrides.
            if (isset($GLOBALS['config'][$name])) {
                $config->setSettingsOverride($GLOBALS['config'][$name]);
            }
        }
        foreach ($this->configFactoryOverrides as $override) {
            $config->addCacheableDependency($override->getCacheableMetadata($name));
        }
        return $config;
    }
}

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