protected function ConfigImportFormTrait::launchImport in Configuration Split 2.0.x
3 calls to ConfigImportFormTrait::launchImport()
- ConfigSplitActivateForm::submitForm in src/
Form/ ConfigSplitActivateForm.php - Form submission handler.
- ConfigSplitDeactivateForm::submitForm in src/
Form/ ConfigSplitDeactivateForm.php - Form submission handler.
- ConfigSplitImportForm::submitForm in src/
Form/ ConfigSplitImportForm.php - Form submission handler.
File
- src/
Form/ ConfigImportFormTrait.php, line 155
Class
- ConfigImportFormTrait
- Trait for config import forms. Extracted from the core form.
Namespace
Drupal\config_split\FormCode
protected function launchImport(StorageComparerInterface $comparer) {
$config_importer = $this
->getConfigImporterFromComparer($comparer);
if ($config_importer
->alreadyImporting()) {
$this
->messenger()
->addStatus($this
->t('Another request may be synchronizing configuration already.'));
}
else {
try {
$sync_steps = $config_importer
->initialize();
$batch = [
'operations' => [],
'finished' => [
self::class,
'finishImportBatch',
],
'title' => t('Synchronizing configuration'),
'init_message' => t('Starting configuration synchronization.'),
'progress_message' => t('Completed step @current of @total.'),
'error_message' => t('Configuration synchronization has encountered an error.'),
];
foreach ($sync_steps as $sync_step) {
$batch['operations'][] = [
[
ConfigImporterBatch::class,
'process',
],
[
$config_importer,
$sync_step,
],
];
}
batch_set($batch);
} catch (ConfigImporterException $e) {
// There are validation errors.
$this
->messenger()
->addError($this
->t('The configuration cannot be imported because it failed validation for the following reasons:'));
foreach ($config_importer
->getErrors() as $message) {
$this
->messenger()
->addError($message);
}
}
}
}