function drush_migrate_tools_migration_list in Migrate Tools 8
Same name and namespace in other branches
- 8.2 migrate_tools.drush.inc \drush_migrate_tools_migration_list()
- 8.3 migrate_tools.drush.inc \drush_migrate_tools_migration_list()
- 8.4 migrate_tools.drush.inc \drush_migrate_tools_migration_list()
Retrieve a list of active migrations.
Parameters
string $group_id: Group machine name - if present, return only migrations in this group.
string $migration_ids: Comma-separated list of migrations - if present, return only these migrations.
Return value
MigrationInterface[][] An array keyed by migration group, each value containing an array of migrations.
3 calls to drush_migrate_tools_migration_list()
File
- ./
migrate_tools.drush.inc, line 422 - Command-line tools to aid performing and developing migrations.
Code
function drush_migrate_tools_migration_list($group_id = '', $migration_ids = '') {
$query = \Drupal::entityQuery('migration');
if ($group_id) {
$query
->condition('third_party_settings.migrate_plus.migration_group', $group_id);
}
$names = $query
->execute();
// Order the migrations according to their dependencies.
/** @var MigrationInterface[] $migrations */
$migrations = \Drupal::entityTypeManager()
->getStorage('migration')
->loadMultiple($names);
if (!empty($migration_ids)) {
$migration_ids = explode(',', Unicode::strtolower($migration_ids));
}
else {
$migration_ids = [];
}
$return = [];
foreach ($migrations as $migration_id => $migration) {
if (empty($migration_ids) || in_array(Unicode::strtolower($migration_id), $migration_ids)) {
$group_id = $migration
->getThirdPartySetting('migrate_plus', 'migration_group');
if (!empty($group_id)) {
$return[$group_id][$migration_id] = $migration;
}
else {
$return['default'][$migration_id] = $migration;
}
}
}
return $return;
}