You are here

protected function LocaleConfigManager::filterOverride in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/locale/src/LocaleConfigManager.php \Drupal\locale\LocaleConfigManager::filterOverride()

Filters override data based on default translatable items.

Parameters

array $override_data: Configuration override data.

array $translatable: Translatable data array. @see self::getTranslatableData()

Return value

array Nested array of any items of $override_data which did not have keys in $translatable. May be empty if $override_data only had items which were also in $translatable.

1 call to LocaleConfigManager::filterOverride()
LocaleConfigManager::updateConfigTranslations in core/modules/locale/src/LocaleConfigManager.php
Updates all configuration translations for the names / languages provided.

File

core/modules/locale/src/LocaleConfigManager.php, line 630

Class

LocaleConfigManager
Manages configuration supported in part by interface translation.

Namespace

Drupal\locale

Code

protected function filterOverride(array $override_data, array $translatable) {
  $filtered_data = [];
  foreach ($override_data as $key => $value) {
    if (isset($translatable[$key])) {

      // If the translatable default configuration has this key, look further
      // for subkeys or ignore this element for scalar values.
      if (is_array($value)) {
        $value = $this
          ->filterOverride($value, $translatable[$key]);
        if (!empty($value)) {
          $filtered_data[$key] = $value;
        }
      }
    }
    else {

      // If this key was not in the translatable default configuration,
      // keep it.
      $filtered_data[$key] = $value;
    }
  }
  return $filtered_data;
}