You are here

public function MigrationController::process in Migrate Tools 8.5

Same name and namespace in other branches
  1. 8.2 src/Controller/MigrationController.php \Drupal\migrate_tools\Controller\MigrationController::process()
  2. 8.3 src/Controller/MigrationController.php \Drupal\migrate_tools\Controller\MigrationController::process()
  3. 8.4 src/Controller/MigrationController.php \Drupal\migrate_tools\Controller\MigrationController::process()

Display process information of a migration entity.

Parameters

\Drupal\migrate_plus\Entity\MigrationGroupInterface $migration_group: The migration group.

\Drupal\migrate_plus\Entity\MigrationInterface $migration: The $migration.

Return value

array A render array as expected by drupal_render().

1 string reference to 'MigrationController::process'
migrate_tools.routing.yml in ./migrate_tools.routing.yml
migrate_tools.routing.yml

File

src/Controller/MigrationController.php, line 193

Class

MigrationController
Returns responses for migrate_tools migration view routes.

Namespace

Drupal\migrate_tools\Controller

Code

public function process(MigrationGroupInterface $migration_group, MigrationInterface $migration) {
  $migration_plugin = $this->migrationPluginManager
    ->createInstance($migration
    ->id(), $migration
    ->toArray());

  // Process information.
  $build['process'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Process'),
  ];
  $header = [
    $this
      ->t('Destination'),
    $this
      ->t('Source'),
    $this
      ->t('Process plugin'),
    $this
      ->t('Default'),
  ];
  $rows = [];
  foreach ($migration_plugin
    ->getProcess() as $destination_id => $process_line) {
    $row = [];
    $row[] = [
      'data' => Html::escape($destination_id),
    ];
    if (isset($process_line[0]['source'])) {
      if (is_array($process_line[0]['source'])) {
        $process_line[0]['source'] = implode(', ', $process_line[0]['source']);
      }
      $row[] = [
        'data' => Xss::filterAdmin($process_line[0]['source']),
      ];
    }
    else {
      $row[] = '';
    }
    if (isset($process_line[0]['plugin'])) {
      $process_line_plugins = [];
      foreach ($process_line as $process_line_row) {
        $process_line_plugins[] = Xss::filterAdmin($process_line_row['plugin']);
      }
      $row[] = [
        'data' => implode(', ', $process_line_plugins),
      ];
    }
    else {
      $row[] = '';
    }
    if (isset($process_line[0]['default_value'])) {
      $row[] = [
        'data' => Xss::filterAdmin($process_line[0]['default_value']),
      ];
    }
    else {
      $row[] = '';
    }
    $rows[] = $row;
  }
  $build['process']['fields'] = [
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => $this
      ->t('No process defined.'),
  ];
  $build['process']['run'] = [
    '#type' => 'link',
    '#title' => $this
      ->t('Run'),
    '#url' => Url::fromRoute('entity.migration.process.run', [
      'migration_group' => $migration_group
        ->id(),
      'migration' => $migration
        ->id(),
    ]),
  ];
  return $build;
}