diff --git a/paragraphs.module b/paragraphs.module index 86348cc..a6a75af 100644 --- a/paragraphs.module +++ b/paragraphs.module @@ -454,40 +454,35 @@ function paragraphs_library_info_alter(&$libraries, $extension) { */ function paragraphs_migration_plugins_alter(array &$migrations) { foreach ($migrations as $key => &$migration) { - // migrate_upgrade/migrate_plus can run this alter multiple times on a - // single migration. Use tags to ensure our alters are only run one time. - if (empty($migration['migration_tags']) || !in_array('paragraphs-processed', $migration['migration_tags'])) { - /** @var \Drupal\migrate\Plugin\MigrationPluginManager $migration_plugin_manager */ - $migration_plugin_manager = \Drupal::service('plugin.manager.migration'); - $migration_stub = $migration_plugin_manager->createStubMigration($migration); - /** @var \Drupal\migrate\Plugin\MigrateSourcePluginManager $source_plugin_manager */ - $source_plugin_manager = \Drupal::service('plugin.manager.migrate.source'); - $source = NULL; - $configuration = $migration['source']; - $source = $source_plugin_manager->createInstance($migration['source']['plugin'], $configuration, $migration_stub); - if ($source) { - if (is_a($migration['class'], FieldMigration::class, TRUE)) { - - // Field storage. - if (is_a($source, Field::class)) { - _paragraphs_migration_entity_type_adjust($migration); - } - - // Field instance. - if (is_a($source, FieldInstance::class)) { - _paragraphs_migration_entity_type_adjust($migration); - _paragraphs_migration_bundle_adjust($migration); - $migration['migration_dependencies']['optional'][] = 'd7_field_collection_type'; - $migration['migration_dependencies']['optional'][] = 'd7_paragraphs_type'; - } + /** @var \Drupal\migrate\Plugin\MigrationPluginManager $migration_plugin_manager */ + $migration_plugin_manager = \Drupal::service('plugin.manager.migration'); + $migration_stub = $migration_plugin_manager->createStubMigration($migration); + /** @var \Drupal\migrate\Plugin\MigrateSourcePluginManager $source_plugin_manager */ + $source_plugin_manager = \Drupal::service('plugin.manager.migrate.source'); + $source = NULL; + $configuration = $migration['source']; + $source = $source_plugin_manager->createInstance($migration['source']['plugin'], $configuration, $migration_stub); + if ($source) { + if (is_a($migration['class'], FieldMigration::class, TRUE)) { + + // Field storage. + if (is_a($source, Field::class)) { + _paragraphs_migration_entity_type_adjust($migration); } - // View Modes. - if (is_a($source, ViewMode::class)) { - _paragraphs_migration_entity_type_adjust($migration, 'targetEntityType'); + // Field instance. + if (is_a($source, FieldInstance::class)) { + _paragraphs_migration_entity_type_adjust($migration); + _paragraphs_migration_bundle_adjust($migration); + $migration['migration_dependencies']['optional']['d7_field_collection_type'] = 'd7_field_collection_type'; + $migration['migration_dependencies']['optional']['d7_paragraphs_type'] = 'd7_paragraphs_type'; } } - $migration['migration_tags'][] = 'paragraphs-processed'; + + // View Modes. + if (is_a($source, ViewMode::class)) { + _paragraphs_migration_entity_type_adjust($migration, 'targetEntityType'); + } } } } @@ -511,7 +506,7 @@ function _paragraphs_migration_bundle_adjust(array &$migration) { if (array_key_exists('plugin', $bundle_process)) { $bundle_process = [$bundle_process]; } - $bundle_process[] = [ + $bundle_process['paragraphs'] = [ 'plugin' => 'paragraphs_process_on_value', 'source_value' => 'entity_type', 'expected_value' => 'field_collection_item', @@ -544,7 +539,7 @@ function _paragraphs_migration_entity_type_adjust(array &$migration, $destinatio ], ]; } - $entity_type_process[] = [ + $entity_type_process['paragraphs'] = [ 'plugin' => 'static_map', 'map' => [ 'field_collection_item' => 'paragraph',