Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / migrate_drupal / src / MigrationConfigurationTrait.php
index b566c821677f4b76c60e9ea7630473180f208a0c..0349d87a7731fbd640ad7187dff89ec55cb13f6e 100644 (file)
@@ -12,6 +12,13 @@ use Drupal\migrate\Plugin\RequirementsInterface;
  */
 trait MigrationConfigurationTrait {
 
+  /**
+   * The follow-up migration tags.
+   *
+   * @var string[]
+   */
+  protected $followUpMigrationTags;
+
   /**
    * Gets the database connection for the source Drupal database.
    *
@@ -96,6 +103,19 @@ trait MigrationConfigurationTrait {
     $all_migrations = $plugin_manager->createInstancesByTag($version_tag);
     $migrations = [];
     foreach ($all_migrations as $migration) {
+      // Skip migrations tagged with any of the follow-up migration tags. They
+      // will be derived and executed after the migrations on which they depend
+      // have been successfully executed.
+      // @see Drupal\migrate_drupal\Plugin\MigrationWithFollowUpInterface
+      if (!empty(array_intersect($migration->getMigrationTags(), $this->getFollowUpMigrationTags()))) {
+        continue;
+      }
+      // Multilingual migrations require migrate_drupal_multilingual.
+      $tags = $migration->getMigrationTags() ?: [];
+      if (in_array('Multilingual', $tags, TRUE) && (!\Drupal::service('module_handler')->moduleExists('migrate_drupal_multilingual'))) {
+        throw new RequirementsException(sprintf("Install migrate_drupal_multilingual to run migration '%s'.", $migration->getPluginId()));
+      }
+
       try {
         // @todo https://drupal.org/node/2681867 We should be able to validate
         //   the entire migration at this point.
@@ -119,6 +139,20 @@ trait MigrationConfigurationTrait {
     return $migrations;
   }
 
+  /**
+   * Returns the follow-up migration tags.
+   *
+   * @return string[]
+   */
+  protected function getFollowUpMigrationTags() {
+    if ($this->followUpMigrationTags === NULL) {
+      $this->followUpMigrationTags = \Drupal::configFactory()
+        ->get('migrate_drupal.settings')
+        ->get('follow_up_migration_tags') ?: [];
+    }
+    return $this->followUpMigrationTags;
+  }
+
   /**
    * Determines what version of Drupal the source database contains.
    *