You are here

function _install_config_locale_overrides_process_batch in Drupal 10

Batch operation callback for install_config_locale_overrides().

Parameters

array $names: The configuration to process.

array $langcodes: The langcodes available on the site.

$context: The batch context.

1 string reference to '_install_config_locale_overrides_process_batch'
_install_config_locale_overrides in core/includes/install.core.inc
Creates a batch to process config translations after installing from config.

File

core/includes/install.core.inc, line 2519
API functions for installing Drupal.

Code

function _install_config_locale_overrides_process_batch(array $names, array $langcodes, &$context) {

  // Get the services we need.
  $language_manager = \Drupal::languageManager();

  /** @var \Drupal\locale\LocaleConfigManager $locale_config_manager */
  $locale_config_manager = \Drupal::service('locale.config_manager');

  /** @var \Drupal\locale\LocaleConfigSubscriber $locale_config_subscriber */
  $locale_config_subscriber = \Drupal::service('locale.config_subscriber');
  foreach ($names as $name) {
    $active_langcode = $locale_config_manager
      ->getActiveConfigLangcode($name);
    foreach ($langcodes as $langcode) {
      if ($langcode === $active_langcode) {
        $config = \Drupal::config($name);
      }
      else {
        $config = $language_manager
          ->getLanguageConfigOverride($langcode, $name);
      }
      $locale_config_subscriber
        ->updateLocaleStorage($config, $langcode);
    }
  }
  $context['finished'] = 1;
}