diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php index 355c33f..6f7969c 100644 --- a/core/modules/migrate/src/Entity/Migration.php +++ b/core/modules/migrate/src/Entity/Migration.php @@ -346,6 +346,12 @@ public function checkRequirements() { } } + /** + * Get the entity manager. + * + * @return \Drupal\Core\Entity\EntityManagerInterface + * The entity manager. + */ protected function getEntityManager() { if (!isset($this->entityManager)) { $this->entityManager = \Drupal::entityManager(); diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php index d112a11..603cb95 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\migrate\Entity\MigrationInterface; +use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\MigrateException; use Drupal\migrate\Plugin\SourceEntityInterface; use Drupal\migrate_drupal\Plugin\MigrateLoadInterface; @@ -79,11 +80,15 @@ public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = N $values['source']['bundle'] = $id; /** @var \Drupal\migrate_drupal\Entity\MigrationInterface $migration */ $migration = $storage->create($values); - if ($migration->getSourcePlugin()->checkRequirements()) { + try { + $migration->getSourcePlugin()->checkRequirements(); $fields = array_keys($migration->getSourcePlugin()->fields()); $migration->process += array_combine($fields, $fields); $migrations[$migration->id()] = $migration; } + catch (RequirementsException $e) { + + } } return $migrations; diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php index 56190de..24b5067 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php @@ -65,29 +65,27 @@ public function getSystemData() { * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { - $plugin = new static( + return new static( $configuration, $plugin_id, $plugin_definition, $migration ); - return $plugin; } /** * {@inheritdoc} */ public function checkRequirements() { - /** @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase $plugin */ if ($this->pluginDefinition['requirements_met'] === TRUE) { - if (isset($plugin_definition['source_provider'])) { - if ($plugin->moduleExists($plugin_definition['source_provider'])) { - if (isset($plugin_definition['minimum_schema_version']) && !$plugin->getModuleSchemaVersion($plugin_definition['source_provider']) < $plugin_definition['minimum_schema_version']) { - throw new RequirementsException(String::format('Required minimum schema version @minimum_schema_version', ['@minimum_schema_version' => $plugin_definition['minimum_schema_version']]), ['minimum_schema_version' => $plugin_definition['minimum_schema_version']]); + if (isset($this->pluginDefinition['source_provider'])) { + if ($this->moduleExists($this->pluginDefinition['source_provider'])) { + if (isset($this->pluginDefinition['minimum_schema_version']) && !$this->getModuleSchemaVersion($this->pluginDefinition['source_provider']) < $this->pluginDefinition['minimum_schema_version']) { + throw new RequirementsException(String::format('Required minimum schema version @minimum_schema_version', ['@minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]), ['minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]); } } else { - throw new RequirementsException(String::format('Missing source provider @provider', ['@provider' => $plugin_definition['source_provider']]), ['source_provider' => $plugin_definition['source_provider']]); + throw new RequirementsException(String::format('Missing source provider @provider', ['@provider' => $this->pluginDefinition['source_provider']]), ['source_provider' => $this->pluginDefinition['source_provider']]); } } }