function ConfigFactoryOverrideBase::filterNestedArray
Same name in other branches
- 9 core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php \Drupal\Core\Config\ConfigFactoryOverrideBase::filterNestedArray()
- 8.9.x core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php \Drupal\Core\Config\ConfigFactoryOverrideBase::filterNestedArray()
- 10 core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php \Drupal\Core\Config\ConfigFactoryOverrideBase::filterNestedArray()
Filters data in nested arrays.
Parameters
array $original_data: Original data array to filter against.
array $override_data: Override data to filter.
Return value
bool TRUE if $override_data was changed, FALSE otherwise.
2 calls to ConfigFactoryOverrideBase::filterNestedArray()
- ConfigFactoryOverrideBase::filterOverride in core/
lib/ Drupal/ Core/ Config/ ConfigFactoryOverrideBase.php - Filters data in the override based on what is currently in configuration.
- TestConfigFactoryOverrideBase::doFilterNestedArray in core/
tests/ Drupal/ Tests/ Core/ Config/ ConfigFactoryOverrideBaseTest.php
File
-
core/
lib/ Drupal/ Core/ Config/ ConfigFactoryOverrideBase.php, line 87
Class
- ConfigFactoryOverrideBase
- Defines a base event listener implementation configuration overrides.
Namespace
Drupal\Core\ConfigCode
protected function filterNestedArray(array $original_data, array &$override_data) {
$changed = FALSE;
foreach ($override_data as $key => $value) {
if (!isset($original_data[$key])) {
// The original data is not there anymore, remove the override.
unset($override_data[$key]);
$changed = TRUE;
}
elseif (is_array($override_data[$key])) {
if (is_array($original_data[$key])) {
// Do the filtering one level deeper.
// Ensure that we track $changed along the way.
if ($this->filterNestedArray($original_data[$key], $override_data[$key])) {
$changed = TRUE;
}
// If no overrides are left under this level, remove the level.
if (empty($override_data[$key])) {
unset($override_data[$key]);
$changed = TRUE;
}
}
else {
// The override is an array but the value is not, this will not go
// well, remove the override.
unset($override_data[$key]);
$changed = TRUE;
}
}
}
return $changed;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.