You are here

public function MigrationPluginsAlterer::alterMigrationPlugins in Paragraphs 8

Adds field collection and paragraph migration dependencies where needed.

Parameters

array[] $migrations: An associative array of migrations keyed by migration ID, the same that is passed to hook_migration_plugins_alter() hooks.

File

src/MigrationPluginsAlterer.php, line 40

Class

MigrationPluginsAlterer
Class MigrationPluginsAlterer.

Namespace

Drupal\paragraphs

Code

public function alterMigrationPlugins(array &$migrations) {
  foreach ($migrations as &$migration) {
    if (!isset($migration['process']) || !is_array($migration['process'])) {
      continue;
    }
    foreach ([
      'entity_type',
      'targetEntityType',
    ] as $process_property) {
      if (isset($migration['process'][$process_property])) {
        $this
          ->paragraphsMigrationEntityTypeAdjust($migration, $process_property);
        $this
          ->paragraphsMigrationBundleAdjust($migration);
        $migration['migration_dependencies']['optional'][] = 'd7_field_collection_type';
        $migration['migration_dependencies']['optional'][] = 'd7_paragraphs_type';
      }
    }
  }
}