You are here

function fieldable_panels_panes_migration_plugins_alter in Fieldable Panels Panes (FPP) 1.0.x

Implements hook_migration_plugins_alter().

File

./fieldable_panels_panes.module, line 16
Module file.

Code

function fieldable_panels_panes_migration_plugins_alter(array &$migrations) {

  /** @var \Drupal\migrate\Plugin\MigrationPluginManager $migration_plugin_manager */
  $migration_plugin_manager = \Drupal::service('plugin.manager.migration');

  /** @var \Drupal\migrate\Plugin\MigrateSourcePluginManager $source_plugin_manager */
  $source_plugin_manager = \Drupal::service('plugin.manager.migrate.source');
  foreach ($migrations as &$migration) {
    $migration_stub = $migration_plugin_manager
      ->createStubMigration($migration);
    $source = $source_plugin_manager
      ->createInstance($migration['source']['plugin'], $migration['source'], $migration_stub);
    if ($source) {
      if (is_a($migration['class'], FieldMigration::class, TRUE)) {

        // Field storage.
        if (is_a($source, Field::class)) {
          _fieldable_panels_panes_entity_type_mapping($migration);
        }

        // Field instance.
        if (is_a($source, FieldInstance::class)) {
          _fieldable_panels_panes_entity_type_mapping($migration);
          $migration['migration_dependencies']['optional']['d7_fieldable_panels_pane_type'] = 'd7_fieldable_panels_pane_type';
        }
      }

      // View Modes.
      if (is_a($source, ViewMode::class)) {
        _fieldable_panels_panes_entity_type_mapping($migration, 'targetEntityType');
      }
    }
  }
}