You are here

public function MigrationPluginManager::createInstances in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate/src/Plugin/MigrationPluginManager.php \Drupal\migrate\Plugin\MigrationPluginManager::createInstances()

Create pre-configured instance of plugin derivatives.

Parameters

array $id: Either the plugin ID or the base plugin ID of the plugins being instantiated. Also accepts an array of plugin IDs and an empty array to load all plugins.

array $configuration: An array of configuration relevant to the plugin instances. Keyed by the plugin ID.

Return value

\Drupal\migrate\Plugin\MigrationInterface[] Fully configured plugin instances.

Throws

\Drupal\Component\Plugin\Exception\PluginException If an instance cannot be created, such as if the ID is invalid.

Overrides MigrationPluginManagerInterface::createInstances

2 calls to MigrationPluginManager::createInstances()
MigrationPluginManager::createInstance in core/modules/migrate/src/Plugin/MigrationPluginManager.php
Creates a pre-configured instance of a plugin.
MigrationPluginManager::createInstancesByTag in core/modules/migrate/src/Plugin/MigrationPluginManager.php
Create migrations given a tag.

File

core/modules/migrate/src/Plugin/MigrationPluginManager.php, line 107

Class

MigrationPluginManager
Plugin manager for migration plugins.

Namespace

Drupal\migrate\Plugin

Code

public function createInstances($migration_id, array $configuration = []) {
  if (empty($migration_id)) {
    $migration_id = array_keys($this
      ->getDefinitions());
  }
  $factory = $this
    ->getFactory();
  $migration_ids = (array) $migration_id;
  $plugin_ids = $this
    ->expandPluginIds($migration_ids);
  $instances = [];
  foreach ($plugin_ids as $plugin_id) {
    $instances[$plugin_id] = $factory
      ->createInstance($plugin_id, isset($configuration[$plugin_id]) ? $configuration[$plugin_id] : []);
  }
  foreach ($instances as $migration) {
    $migration
      ->set('migration_dependencies', array_map([
      $this,
      'expandPluginIds',
    ], $migration
      ->getMigrationDependencies()));
  }

  // Sort the migrations based on their dependencies.
  return $this
    ->buildDependencyMigration($instances, []);
}