function locale_config_batch_build
Same name and namespace in other branches
- 10 core/modules/locale/locale.bulk.inc \locale_config_batch_build()
- 11.x core/modules/locale/locale.bulk.inc \locale_config_batch_build()
- 9 core/modules/locale/locale.bulk.inc \locale_config_batch_build()
- 8.9.x core/modules/locale/locale.bulk.inc \locale_config_batch_build()
Creates a locale batch to refresh specific configuration.
Parameters
array $names: List of configuration object names (which are strings) to update.
array $langcodes: List of language codes to refresh.
array $options: (optional) An array with options that can have the following elements:
- 'finish_feedback': Whether or not to give feedback to the user when the batch is finished. Defaults to TRUE.
bool $update_default_config_langcodes: Determines whether default configuration langcodes should be updated. This Should only happen during site and extension install.
Return value
array The batch definition.
Deprecated
in drupal:11.4.0 and is removed from drupal:13.0.0. Use \Drupal::service(LocaleConfigBatch::class)->buildBatch() instead the arguments have changed.
See also
\Drupal\locale\LocaleConfigBatch::batchUpdateConfigTranslations()
https://www.drupal.org/node/3589759
File
-
core/
modules/ locale/ locale.bulk.inc, line 308
Code
function locale_config_batch_build(array $names, array $langcodes, array $options = [], bool $update_default_config_langcodes = FALSE) {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service(LocaleConfigBatch::class)->buildBatch() instead, the arguments have changed. See https://www.drupal.org/node/3589759', E_USER_DEPRECATED);
$options += [
'finish_feedback' => TRUE,
];
$batch_builder = (new BatchBuilder())->setTitle(t('Updating configuration translations'))
->setInitMessage(t('Starting configuration update'))
->setErrorMessage(t('Error updating configuration translations'));
if ($update_default_config_langcodes && \Drupal::languageManager()->getDefaultLanguage()
->getId() !== 'en') {
$batch_builder->addOperation(LocaleConfigBatch::class . ':batchUpdateDefaultConfigLangcodes');
}
// Chunking the array of names into batches of 20 for better performance.
$name_chunks = array_chunk($names, 20);
foreach ($name_chunks as $chunk) {
// During installation the caching of configuration objects is disabled so
// it is very expensive to initialize the \Drupal::config() object on each
// request. We batch a small number of configuration object upgrades
// together to improve the overall performance of the process.
$batch_builder->addOperation(LocaleConfigBatch::class . ':batchUpdateConfigTranslations', [
$chunk,
$langcodes,
]);
}
if (!empty($options['finish_feedback'])) {
$batch_builder->setFinishCallback(LocaleConfigBatch::class . ':batchFinished');
}
return $batch_builder->toArray();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.