You are here

public function Migration::getProcessPlugins in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate/src/Plugin/Migration.php \Drupal\migrate\Plugin\Migration::getProcessPlugins()
  2. 10 core/modules/migrate/src/Plugin/Migration.php \Drupal\migrate\Plugin\Migration::getProcessPlugins()

Returns the process plugins.

Parameters

array $process: A process configuration array.

Return value

\Drupal\migrate\Plugin\MigrateProcessInterface[][] An associative array. The keys are the destination property names. Values are process pipelines. Each pipeline contains an array of plugins.

Overrides MigrationInterface::getProcessPlugins

File

core/modules/migrate/src/Plugin/Migration.php, line 358

Class

Migration
Defines the Migration plugin.

Namespace

Drupal\migrate\Plugin

Code

public function getProcessPlugins(array $process = NULL) {
  if (!isset($process)) {
    $process = $this
      ->getProcess();
  }
  $index = serialize($process);
  if (!isset($this->processPlugins[$index])) {
    $this->processPlugins[$index] = [];
    foreach ($this
      ->getProcessNormalized($process) as $property => $configurations) {
      $this->processPlugins[$index][$property] = [];
      if (!is_array($configurations) && !$this->processPlugins[$index][$property]) {
        throw new MigrateException(sprintf("Process configuration for '{$property}' must be an array", $property));
      }
      foreach ($configurations as $configuration) {
        if (isset($configuration['source'])) {
          $this->processPlugins[$index][$property][] = $this->processPluginManager
            ->createInstance('get', $configuration, $this);
        }

        // Get is already handled.
        if ($configuration['plugin'] != 'get') {
          $this->processPlugins[$index][$property][] = $this->processPluginManager
            ->createInstance($configuration['plugin'], $configuration, $this);
        }
        if (!$this->processPlugins[$index][$property]) {
          throw new MigrateException("Invalid process configuration for {$property}");
        }
      }
    }
  }
  return $this->processPlugins[$index];
}