diff --git a/islandora_spreadsheet_ingest.services.yml b/islandora_spreadsheet_ingest.services.yml index 3128206..f8da1b7 100644 --- a/islandora_spreadsheet_ingest.services.yml +++ b/islandora_spreadsheet_ingest.services.yml @@ -26,6 +26,7 @@ services: - '@entity_type.manager' - '@cache_tags.invalidator' - '@islandora_spreadsheet_ingest.migration_group_deriver' + - '@plugin.manager.migration' islandora_spreadsheet_ingest.deferred_ingest.queue: class: Drupal\Core\Queue\DatabaseQueue factory: ['@queue', 'get'] diff --git a/src/Form/Ingest/FileUpload.php b/src/Form/Ingest/FileUpload.php index 9f5829e..d39f0a4 100644 --- a/src/Form/Ingest/FileUpload.php +++ b/src/Form/Ingest/FileUpload.php @@ -303,15 +303,7 @@ protected function mapMappingFromMigrationGroup($id) { $storage = $etm->getStorage('migration'); $names = $storage->getQuery()->condition('migration_group', $id)->execute(); - $migrations = $mpm->createinstances( - $names, - array_map( - function ($a) { - return $a->toArray(); - }, - $storage->loadMultiple($names) - ) - ); + $migrations = $mpm->createInstances($names); $start = 0; $map_migration = function ($migration) use (&$start) { diff --git a/src/MigrationDeriver.php b/src/MigrationDeriver.php index 8dd5981..3104574 100644 --- a/src/MigrationDeriver.php +++ b/src/MigrationDeriver.php @@ -6,7 +6,8 @@ use Drupal\Core\Cache\CacheTagsInvalidatorInterface; use Psr\Log\LoggerInterface; -use Drupal\migrate_plus\Entity\MigrationInterface; +use Drupal\migrate\Plugin\MigrationInterface; +use Drupal\migrate\Plugin\MigrationPluginManagerInterface; /** * Derive migrations for a given request. @@ -55,6 +56,13 @@ class MigrationDeriver implements MigrationDeriverInterface { */ protected $cacheInvalidator; + /** + * The migration plugin manager service. + * + * @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface + */ + protected $migrationPluginManager; + /** * Constructor. */ @@ -62,7 +70,8 @@ public function __construct( LoggerInterface $logger, EntityTypeManagerInterface $entity_type_manager, CacheTagsInvalidatorInterface $invalidator, - MigrationGroupDeriverInterface $migration_group_deriver + MigrationGroupDeriverInterface $migration_group_deriver, + MigrationPluginManagerInterface $migration_plugin_manager ) { $this->logger = $logger; $this->entityTypeManager = $entity_type_manager; @@ -70,6 +79,7 @@ public function __construct( $this->requestStorage = $this->entityTypeManager->getStorage('isi_request'); $this->migrationStorage = $this->entityTypeManager->getStorage('migration'); $this->cacheInvalidator = $invalidator; + $this->migrationPluginManager = $migration_plugin_manager; } /** @@ -109,7 +119,7 @@ public function getUsedColumns(array $mappings) { /** * Remap referenced migration dependencies to their new names. * - * @param \Drupal\migrate_plus\Entity\MigrationInterface $migration + * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The original migration from which to scrape the dependencies. * @param string $new_mg * The name of the new migration group, such that we can derive the new @@ -156,7 +166,7 @@ protected function deriveMigrationName($mg_name, $target) { /** * Determine if a migration appears to be a part of the same migration group. * - * @param \Drupal\migrate_plus\Entity\MigrationInterface $mig + * @param \Drupal\migrate\Plugin\MigrationInterface $mig * The original migration for comparison. * @param string $target * The name/id of the migration to test. @@ -165,7 +175,7 @@ protected function deriveMigrationName($mg_name, $target) { * TRUE if it is the same; otherwise, FALSE. */ protected function sameMigrationGroup(MigrationInterface $mig, $target) { - $loaded_target = $this->migrationStorage->load($target); + $loaded_target = $this->migrationPluginManager->createInstance($target); $mg = $loaded_target->get('migration_group'); return $mg && $mg == $mig->get('migration_group'); } @@ -175,7 +185,7 @@ protected function sameMigrationGroup(MigrationInterface $mig, $target) { * * @param array $steps * The array of process plugin definitions to map. - * @param \Drupal\migrate_plus\Entity\MigrationInterface $mig + * @param \Drupal\migrate\Plugin\MigrationInterface $mig * The original migration for comparison. * @param string $mg_name * The name of the migration group we are populating. @@ -214,7 +224,7 @@ protected function mapStepMigrations(array $steps, MigrationInterface $mig, $mg_ * * @param array $processes * Associative array mapping field names to process info. - * @param \Drupal\migrate_plus\Entity\MigrationInterface $mig + * @param \Drupal\migrate\Plugin\MigrationInterface $mig * The migration from which we are deriving another migration. * @param string $mg_name * The migration group we are populating. @@ -239,7 +249,7 @@ public function createAll(RequestInterface $request) { assert($this->entityTypeManager->getStorage('migration_group')->load($mg_name)); foreach ($request->getMappings() as $name => $info) { - $original_migration = $this->migrationStorage->load($info['original_migration_id']); + $original_migration = $this->migrationPluginManager->createInstance($info['original_migration_id']); $derived_name = $this->deriveMigrationName($mg_name, $name); $info = [ 'id' => $derived_name,