function eck_migration_plugins_alter in Entity Construction Kit (ECK) 8
Implements hook_migration_plugins_alter().
File
- ./
eck.module, line 345 - Contains hook implementations.
Code
function eck_migration_plugins_alter(array &$migrations) {
foreach ($migrations as $key => &$migration) {
// Do not alter a migration that is already configured.
if (strstr($key, 'migration_config_deriver:')) {
continue;
}
/** @var \Drupal\migrate\Plugin\MigrationPluginManager $migration_plugin_manager */
$migration_plugin_manager = \Drupal::service('plugin.manager.migration');
$migration_stub = $migration_plugin_manager
->createStubMigration($migration);
/** @var \Drupal\migrate\Plugin\MigrateSourcePluginManager $source_plugin_manager */
$source_plugin_manager = \Drupal::service('plugin.manager.migrate.source');
$source = NULL;
$configuration = $migration['source'];
$source = $source_plugin_manager
->createInstance($migration['source']['plugin'], $configuration, $migration_stub);
if ($source) {
if (is_a($migration['class'], FieldMigration::class, TRUE)) {
// Field storage.
if (is_a($source, Field::class)) {
$migration['migration_dependencies']['required'][] = 'd7_eck_type';
}
// Field instance.
if (get_class($source) === FieldInstance::class) {
$migration['migration_dependencies']['required'][] = 'd7_eck_bundle';
}
}
}
}
}