function Config::getOriginal
Same name in other branches
- 9 core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::getOriginal()
- 8.9.x core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::getOriginal()
- 11.x core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::getOriginal()
Gets original data from this configuration object.
Original data is the data as it is immediately after loading from configuration storage before any changes. If this is a new configuration object it will be an empty array.
Parameters
string $key: A string that maps to a key within the configuration data.
bool $apply_overrides: Apply any overrides to the original data. Defaults to TRUE.
Return value
mixed The data that was requested.
Overrides StorableConfigBase::getOriginal
See also
\Drupal\Core\Config\Config::get()
File
-
core/
lib/ Drupal/ Core/ Config/ Config.php, line 270
Class
- Config
- Defines the default configuration object.
Namespace
Drupal\Core\ConfigCode
public function getOriginal($key = '', $apply_overrides = TRUE) {
$original_data = $this->originalData;
if ($apply_overrides) {
// Apply overrides.
if (isset($this->moduleOverrides) && is_array($this->moduleOverrides)) {
$original_data = NestedArray::mergeDeepArray([
$original_data,
$this->moduleOverrides,
], TRUE);
}
if (isset($this->settingsOverrides) && is_array($this->settingsOverrides)) {
$original_data = NestedArray::mergeDeepArray([
$original_data,
$this->settingsOverrides,
], TRUE);
}
}
if (empty($key)) {
return $original_data;
}
else {
$parts = explode('.', $key);
if (count($parts) == 1) {
return $original_data[$key] ?? NULL;
}
else {
$value = NestedArray::getValue($original_data, $parts, $key_exists);
return $key_exists ? $value : NULL;
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.