diff -u b/core/modules/file/migration_templates/d7_file.yml b/core/modules/file/migration_templates/d7_file.yml --- b/core/modules/file/migration_templates/d7_file.yml +++ b/core/modules/file/migration_templates/d7_file.yml @@ -1,7 +1,7 @@ # Every migration that references a file by Drupal 7 fid should specify this # migration as an optional dependency. id: d7_file -label: Public Files +label: Files audit: true migration_tags: - Drupal 7 diff -u b/core/modules/file/migration_templates/d7_file_private.yml b/core/modules/file/migration_templates/d7_file_private.yml --- b/core/modules/file/migration_templates/d7_file_private.yml +++ b/core/modules/file/migration_templates/d7_file_private.yml @@ -1,5 +1,5 @@ id: d7_file_private -label: Private Files +label: Files audit: true migration_tags: - Drupal 7 diff -u b/core/modules/migrate/src/Audit/AuditException.php b/core/modules/migrate/src/Audit/AuditException.php --- b/core/modules/migrate/src/Audit/AuditException.php +++ b/core/modules/migrate/src/Audit/AuditException.php @@ -20,7 +20,7 @@ * (optional) The previous exception. */ public function __construct(MigrationInterface $migration, $message, \Exception $previous = NULL) { - $message = 'Cannot audit migration ' . $migration->id() . ': ' . $message; + $message = sprintf('Cannot audit migration %s: %s', $migration->id(), $message); parent::__construct($message, 0, $previous); } diff -u b/core/modules/migrate/src/Audit/IdAuditor.php b/core/modules/migrate/src/Audit/IdAuditor.php --- b/core/modules/migrate/src/Audit/IdAuditor.php +++ b/core/modules/migrate/src/Audit/IdAuditor.php @@ -20,14 +20,16 @@ return []; } + $interface = MaximumValueInterface::class; + $destination = $migration->getDestinationPlugin(); if (!$destination instanceof MaximumValueInterface) { - throw new AuditException($migration, 'Destination plugin does not implement ' . MaximumValueInterface::class); + throw new AuditException($migration, "Destination does not implement $interface"); } $id_map = $migration->getIdMap(); if (!$id_map instanceof MaximumValueInterface) { - throw new AuditException($migration, 'ID map plugin does not implement ' . MaximumValueInterface::class); + throw new AuditException($migration, "ID map does not implement $interface"); } if ($destination->max() > $id_map->max()) { diff -u b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php --- b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php +++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php @@ -13,7 +13,6 @@ use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateMessageInterface; use Drupal\migrate\Plugin\MigrateIdMapInterface; -use Drupal\migrate\Plugin\MigrationPluginManagerInterface; use Drupal\migrate\Row; use Drupal\migrate\Event\MigrateEvents; use Drupal\migrate\Event\MigrateMapSaveEvent; @@ -44,13 +43,6 @@ protected $eventDispatcher; /** - * The migration plugin manager. - * - * @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface - */ - protected $migrationPluginManager; - - /** * The migration map table name. * * @var string @@ -163,14 +155,11 @@ * The migration to do. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher. - * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager - * The migration plugin manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher, MigrationPluginManagerInterface $migration_plugin_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->migration = $migration; $this->eventDispatcher = $event_dispatcher; - $this->migrationPluginManager = $migration_plugin_manager; $this->message = new MigrateMessage(); } @@ -951,7 +940,7 @@ } ); if (empty($destination_ids)) { - throw new \LogicException('TODO'); + throw new \LogicException('Cannot determine the highest migrated ID without an integer ID column'); } $field_name = key($destination_ids); @@ -966,12 +955,16 @@ // If there's a bundle, it means we have a derived migration and we need to // find all the mapping tables from the related derived migrations. if ($base_id = substr($migration_id, 0, strpos($migration_id, ':'))) { - $migrations = $this->migrationPluginManager->getDefinitions(); + // @TODO Inject the plugin manager as a dependency. + /** @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_manager */ + $migration_manager = \Drupal::service('plugin.manager.migration'); + + $migrations = $migration_manager->getDefinitions(); foreach ($migrations as $migration_id => $migration) { if ($migration['id'] == $base_id) { // Get this derived migration's mapping table and add it to the list // of mapping tables to look in for the highest ID. - $stub = $this->migrationPluginManager->createInstance($migration_id); + $stub = $migration_manager->createInstance($migration_id); $map_tables[$migration_id] = $stub->getIdMap()->mapTableName(); } } reverted: --- b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php +++ a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php @@ -232,8 +232,7 @@ ->willReturn($plugin); /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher */ $event_dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $map = new TestSqlIdMap($database, [], 'sql', [], $migration, $event_dispatcher); - $migration_plugin_manager = $this->getMock('Drupal\migrate\Plugin\MigrationPluginManagerInterface'); - $map = new TestSqlIdMap($database, [], 'sql', [], $migration, $event_dispatcher, $migration_plugin_manager); $map->getDatabase(); } reverted: --- b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php +++ a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php @@ -111,9 +111,8 @@ ->method('getDestinationPlugin') ->willReturn($plugin); $event_dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $migration_plugin_manager = $this->getMock('Drupal\migrate\Plugin\MigrationPluginManagerInterface'); + $id_map = new TestSqlIdMap($this->database, [], 'sql', [], $migration, $event_dispatcher); - $id_map = new TestSqlIdMap($this->database, [], 'sql', [], $migration, $event_dispatcher, $migration_plugin_manager); $migration ->method('getIdMap') ->willReturn($id_map); reverted: --- b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php +++ a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php @@ -6,7 +6,6 @@ use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateException; use Drupal\migrate\Plugin\migrate\id_map\Sql; -use Drupal\migrate\Plugin\MigrationPluginManagerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -29,12 +28,10 @@ * The migration to do. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher service. - * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager - * The migration plugin manager. */ + public function __construct(Connection $database, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher) { - public function __construct(Connection $database, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher, MigrationPluginManagerInterface $migration_plugin_manager) { $this->database = $database; + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $event_dispatcher); - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $event_dispatcher, $migration_plugin_manager); } /**