function migrate_devel_revert_missing_config in Migrate Devel 8
Same name and namespace in other branches
- 8.2 migrate_devel.drush.inc \migrate_devel_revert_missing_config()
Reverts missing config for a specific config type.
Parameters
string $type:
1 call to migrate_devel_revert_missing_config()
- migrate_devel_revert_migrate_config in ./
migrate_devel.drush.inc - Reverts migrate config for migrate_plus
File
- ./
migrate_devel.drush.inc, line 93 - File for Drush Integration.
Code
function migrate_devel_revert_missing_config($type) {
/* @var ConfigRevertInterface $config_revert */
$config_revert = \Drupal::service('config_update.config_update');
// Now we need to add any new migrations.
/* @var ConfigListInterface $config_lister */
$config_lister = \Drupal::service('config_update.config_list');
// Add any new migrations we need to.
list($active_list, $install_list, $optional_list) = $config_lister
->listConfig('type', $type);
$missing = array_diff($install_list, $active_list);
/* @var StorageInterface $config_reader */
$config_reader = \Drupal::service('config_update.extension_storage');
foreach ($missing as $name) {
$config = $config_reader
->read($name);
$config_type = $config_lister
->getTypeNameByConfigName($name);
$definition = $config_lister
->getType($config_type);
$id_key = $definition
->getKey('id');
if ($config_revert
->import($config_type, $config[$id_key])) {
drush_log(dt('Imported @config', [
'@config' => $name,
]), LogLevel::ALERT);
}
}
}