You are here

protected static function DrupalMigrationGenerator::createEntityFromPlugin in Drupal-to-Drupal data migration 8.3

Create a configuration entity from a core migration plugin's configuration.

@todo: Remove and replace calls to use Migration::createEntityFromPlugin() when there's a migrate_plus release containing it we can have a dependency on.

Parameters

string $plugin_id: ID of a migration plugin managed by MigrationPluginManager.

string $new_plugin_id: ID to use for the new configuration entity.

Return value

\Drupal\migrate_plus\Entity\MigrationInterface A Migration configuration entity (not saved to persistent storage).

2 calls to DrupalMigrationGenerator::createEntityFromPlugin()
DrupalMigrationGenerator::createContentMigration in src/DrupalMigrationGenerator.php
Setup the migration for a given WordPress content type.
DrupalMigrationGenerator::createMigrations in src/DrupalMigrationGenerator.php
Creates a set of WordPress import migrations based on configuration settings.

File

src/DrupalMigrationGenerator.php, line 270

Class

DrupalMigrationGenerator
Functionality to construct Drupal migrations from broad configuration settings.

Namespace

Drupal\migrate_d2d

Code

protected static function createEntityFromPlugin($plugin_id, $new_plugin_id) {

  /** @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface $plugin_manager */
  $plugin_manager = \Drupal::service('plugin.manager.migration');
  $migration_plugin = $plugin_manager
    ->createInstance($plugin_id);
  $entity_array['id'] = $new_plugin_id;
  $entity_array['migration_tags'] = $migration_plugin
    ->get('migration_tags');
  $entity_array['label'] = $migration_plugin
    ->label();
  $entity_array['source'] = $migration_plugin
    ->getSourceConfiguration();
  $entity_array['destination'] = $migration_plugin
    ->getDestinationConfiguration();
  $entity_array['process'] = $migration_plugin
    ->getProcess();
  $entity_array['migration_dependencies'] = $migration_plugin
    ->getMigrationDependencies();
  $migration_entity = Migration::create($entity_array);
  return $migration_entity;
}