Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::hasOverrides()
  2. 9 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:

array(
  'foo' => array(
    'bar' => 'baz',
  ),
);

A key of 'foo.bar' would map to the string 'baz'. However, a key of 'foo' would map to the array('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;
  }
}