function Config::hasOverrides

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::hasOverrides()
  2. 8.9.x core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::hasOverrides()
  3. 11.x core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::hasOverrides()

Determines if overrides are applied to a key for this configuration object.

Parameters

string $key: (optional) A string that maps to a key within the configuration data. For instance in the following configuration array:

[
    'foo' => [
        'bar' => 'baz',
    ],
];

A key of 'foo.bar' would map to the string 'baz'. However, a key of 'foo' would map to the ['bar' => 'baz']. If not supplied TRUE will be returned if there are any overrides at all for this configuration object.

Return value

bool TRUE if there are any overrides for the key, otherwise FALSE.

File

core/lib/Drupal/Core/Config/Config.php, line 318

Class

Config
Defines the default configuration object.

Namespace

Drupal\Core\Config

Code

public function hasOverrides($key = '') {
    if (empty($key)) {
        return !(empty($this->moduleOverrides) && empty($this->settingsOverrides));
    }
    else {
        $parts = explode('.', $key);
        $override_exists = FALSE;
        if (isset($this->moduleOverrides) && is_array($this->moduleOverrides)) {
            $override_exists = NestedArray::keyExists($this->moduleOverrides, $parts);
        }
        if (!$override_exists && isset($this->settingsOverrides) && is_array($this->settingsOverrides)) {
            $override_exists = NestedArray::keyExists($this->settingsOverrides, $parts);
        }
        return $override_exists;
    }
}

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