ConfigFactory::doGet

protected ConfigFactory::doGet($name, $immutable = TRUE)

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.

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(array($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(array($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;
  }
}
doc_Drupal
2016-10-29 08:53:13
Comments
Leave a Comment

Please login to continue.