You are here

public function MigrationController::destination in Migrate Tools 8.2

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

Displays destination information of a migration entity.

Parameters

string $migration_group: Machine name of the migration's group.

string $migration: Machine name of the migration.

Return value

array A render array as expected by drupal_render().

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

File

src/Controller/MigrationController.php, line 222

Class

MigrationController
Returns responses for migrate_tools migration view routes.

Namespace

Drupal\migrate_tools\Controller

Code

public function destination($migration_group, $migration) {

  /** @var MigrationInterface $migration */
  $migration = $this->migrationConfigEntityPluginManager
    ->createInstance($migration);

  // Destination field information.
  $build['destination'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Destination'),
    '#group' => 'detail',
    '#description' => $this
      ->t('<p>These are the fields available in the destination plugin of this migration task. The machine names are those available to be used as the keys in the process pipeline.</p>'),
    '#attributes' => [
      'id' => 'migration-detail-destination',
    ],
  ];
  $destination = $migration
    ->getDestinationPlugin();
  $build['destination']['type'] = [
    '#type' => 'item',
    '#title' => $this
      ->t('Type'),
    '#markup' => Xss::filterAdmin($destination
      ->getPluginId()),
  ];
  $header = [
    $this
      ->t('Machine name'),
    $this
      ->t('Description'),
  ];
  $rows = [];
  $destination_fields = $destination
    ->fields() ?: [];
  foreach ($destination_fields as $machine_name => $description) {
    $rows[] = [
      [
        'data' => Html::escape($machine_name),
      ],
      [
        'data' => Xss::filterAdmin($description),
      ],
    ];
  }
  $build['destination']['fields'] = [
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => $this
      ->t('No fields'),
  ];
  return $build;
}