You are here

function config_distro_batch_alter in Config Distro 8

Implements hook_batch_alter().

Switches out the default batch 'finished' callback class for our custom version.

By testing for the presence of \Drupal\Core\Config\ConfigImporterBatch, which was introduced to core in 8.6.x, we restrict our change to sites running that or a later version.

See also

\Drupal\config_distro\Form\ConfigDistroImportForm::finishBatch()

File

./config_distro.module, line 20
Framework for managing configuration updates from distributions.

Code

function config_distro_batch_alter(&$batch) {

  // Detect the batch generated in
  // \Drupal\config\Form\ConfigSync::submitForm().
  if (isset($batch['form_state']) && $batch['form_state']
    ->getValue('form_id') === 'config_distro_import_form' && !empty($batch['sets'][0]['finished'][0]) && $batch['sets'][0]['finished'][0] === 'Drupal\\Core\\Config\\Importer\\ConfigImporterBatch') {
    $batch['sets'][0]['finished'][0] = 'Drupal\\config_distro\\ConfigDistroConfigImporterBatch';
  }
}