config_import_test.module 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * @file
  4. * Provides configuration import test helpers.
  5. */
  6. use Drupal\Core\Config\ConfigImporter;
  7. /**
  8. * Implements hook_config_import_steps_alter().
  9. */
  10. function config_import_test_config_import_steps_alter(&$sync_steps) {
  11. $sync_steps[] = '_config_import_test_config_import_steps_alter';
  12. }
  13. /**
  14. * Implements configuration synchronization step added by an alter for testing.
  15. *
  16. * @param array $context
  17. * The batch context.
  18. * @param \Drupal\Core\Config\ConfigImporter $config_importer
  19. * The configuration importer.
  20. */
  21. function _config_import_test_config_import_steps_alter(&$context, ConfigImporter $config_importer) {
  22. $GLOBALS['hook_config_test']['config_import_steps_alter'] = TRUE;
  23. if (\Drupal::state()->get('config_import_steps_alter.error', FALSE)) {
  24. $context['results']['errors'][] = '_config_import_test_config_import_steps_alter batch error';
  25. $config_importer->logError('_config_import_test_config_import_steps_alter ConfigImporter error');
  26. }
  27. $context['finished'] = 1;
  28. return;
  29. }