Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / migrate / src / Plugin / Migration.php
index 13092e777585addbc61d68433d40a1eb0c281265..20b8ae877b9033cd8f6d314b20d467b9dc05b959 100644 (file)
@@ -154,6 +154,17 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
    */
   protected $migration_tags = [];
 
+  /**
+   * Whether the migration is auditable.
+   *
+   * If set to TRUE, the migration's IDs will be audited. This means that, if
+   * the highest destination ID is greater than the highest source ID, a warning
+   * will be displayed that entities might be overwritten.
+   *
+   * @var bool
+   */
+  protected $audit = FALSE;
+
   /**
    * These migrations, if run, must be executed before this migration.
    *
@@ -205,7 +216,7 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
   protected $sourcePluginManager;
 
   /**
-   * Thep process plugin manager.
+   * The process plugin manager.
    *
    * @var \Drupal\migrate\Plugin\MigratePluginManager
    */
@@ -312,6 +323,8 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
    *
    * @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.x. Use
    *   more specific getters instead.
+   *
+   * @see https://www.drupal.org/node/2873795
    */
   public function get($property) {
     return isset($this->$property) ? $this->$property : NULL;
@@ -397,7 +410,7 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
    */
   public function getDestinationPlugin($stub_being_requested = FALSE) {
     if ($stub_being_requested && !empty($this->destination['no_stub'])) {
-      throw new MigrateSkipRowException();
+      throw new MigrateSkipRowException('Stub requested but not made because no_stub configuration is set.');
     }
     if (!isset($this->destinationPlugin)) {
       $this->destinationPlugin = $this->destinationPluginManager->createInstance($this->destination['plugin'], $this->destination, $this);
@@ -541,7 +554,6 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
     return $this;
   }
 
-
   /**
    * {@inheritdoc}
    */
@@ -570,7 +582,7 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
    */
   public function mergeProcessOfProperty($property, array $process_of_property) {
     // If we already have a process value then merge the incoming process array
-    //otherwise simply set it.
+    // otherwise simply set it.
     $current_process = $this->getProcess();
     if (isset($current_process[$property])) {
       $this->process = NestedArray::mergeDeepArray([$current_process, $this->getProcessNormalized([$property => $process_of_property])], TRUE);
@@ -607,19 +619,22 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
   }
 
   /**
-   * Find migration dependencies from the migration and the iterator plugins.
+   * Find migration dependencies from migration_lookup and sub_process plugins.
+   *
+   * @param array $process
+   *   A process configuration array.
    *
-   * @param $process
    * @return array
+   *   The migration dependencies.
    */
   protected function findMigrationDependencies($process) {
     $return = [];
     foreach ($this->getProcessNormalized($process) as $process_pipeline) {
       foreach ($process_pipeline as $plugin_configuration) {
-        if ($plugin_configuration['plugin'] == 'migration') {
+        if (in_array($plugin_configuration['plugin'], ['migration', 'migration_lookup'], TRUE)) {
           $return = array_merge($return, (array) $plugin_configuration['migration']);
         }
-        if ($plugin_configuration['plugin'] == 'iterator') {
+        if (in_array($plugin_configuration['plugin'], ['iterator', 'sub_process'], TRUE)) {
           $return = array_merge($return, $this->findMigrationDependencies($plugin_configuration['process']));
         }
       }
@@ -675,4 +690,11 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
     return $this->migration_tags;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuditable() {
+    return (bool) $this->audit;
+  }
+
 }