You are here

function migrate_devel_revert_migrate_config in Migrate Devel 8

Same name and namespace in other branches
  1. 8.2 migrate_devel.drush.inc \migrate_devel_revert_migrate_config()

Reverts migrate config for migrate_plus

Parameters

CachedDiscoveryInterface $discovery:

1 call to migrate_devel_revert_migrate_config()
migrate_devel_rebuild_migrations in ./migrate_devel.drush.inc
Clears cache for migrations and reverts config of migrations if needed.

File

./migrate_devel.drush.inc, line 69
File for Drush Integration.

Code

function migrate_devel_revert_migrate_config($discovery) {

  // If migrate_plus and config_update exists, revert the config.
  if (\Drupal::moduleHandler()
    ->moduleExists('config_update')) {

    /* @var $config_revert ConfigRevertInterface */
    $config_revert = \Drupal::service('config_update.config_update');
    foreach ($discovery
      ->getDefinitions() as $definition) {
      $config_revert
        ->revert('migration', $definition['id']);
    }
    drush_log(dt('Reverted Existing Migration Configs'));

    // Revert missing config
    migrate_devel_revert_missing_config('migration');
  }
  else {
    drush_log(dt('Missing config_update for revert.'));
  }
}