You are here

public function MigrationController::destination in Migrate Tools 8.5

Same name and namespace in other branches
  1. 8.2 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

\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::destination'
migrate_tools.routing.yml in ./migrate_tools.routing.yml
migrate_tools.routing.yml

File

src/Controller/MigrationController.php, line 267

Class

MigrationController
Returns responses for migrate_tools migration view routes.

Namespace

Drupal\migrate_tools\Controller

Code

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

  // 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_plugin
    ->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;
}