You are here

protected function MigrationPluginAlterer::switchIdMapPlugin in Media Migration 8

Re-adds ID map plugin config "smart_sql" which can handle long IDs.

This method is required only because migrate_plus does not define the ID map plugin property configuration (or scheme) for its migration entities.

Parameters

array $migrations: The array of migration plugins.

1 call to MigrationPluginAlterer::switchIdMapPlugin()
MigrationPluginAlterer::alter in modules/media_migration_tools/src/MigrationPluginAlterer.php
Alters migrate plugins.

File

modules/media_migration_tools/src/MigrationPluginAlterer.php, line 32

Class

MigrationPluginAlterer
Migration plugin alterer for "fixing" migrations provided by Migrate Tools.

Namespace

Drupal\media_migration_tools

Code

protected function switchIdMapPlugin(array &$migrations) {

  // Collect all derived media migrations.
  $file_to_media_migrations = array_filter($migrations, function (array $migration_definition) {
    $migration_tags = $migration_definition['migration_tags'] ?? [];
    return in_array(MediaMigration::MIGRATION_TAG_MAIN, $migration_tags, TRUE) && !empty($migration_definition['source']['destination_media_type_id']) && empty($migration_definition['idMap']);
  });

  // Re-add the missing ID map plugin configuration.
  foreach ($file_to_media_migrations as $migration_plugin_id => $file_to_media_migration_def) {
    $migrations[$migration_plugin_id]['idMap'] = [
      'plugin' => 'smart_sql',
    ];
  }
}