W3cubDocs

/Drupal 8

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!ConfigFactory.php/function/ConfigFactory::doGet/8.1.x