public function MigrationController::source in Migrate Tools 8.5
Same name and namespace in other branches
- 8.2 src/Controller/MigrationController.php \Drupal\migrate_tools\Controller\MigrationController::source()
- 8.3 src/Controller/MigrationController.php \Drupal\migrate_tools\Controller\MigrationController::source()
- 8.4 src/Controller/MigrationController.php \Drupal\migrate_tools\Controller\MigrationController::source()
Display source 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::source'
File
- src/
Controller/ MigrationController.php, line 119
Class
- MigrationController
- Returns responses for migrate_tools migration view routes.
Namespace
Drupal\migrate_tools\ControllerCode
public function source(MigrationGroupInterface $migration_group, MigrationInterface $migration) {
// Source field information.
$build['source'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Source'),
'#group' => 'detail',
'#description' => $this
->t('<p>These are the fields available from the source of this migration task. The machine names listed here may be used as sources in the process pipeline.</p>'),
'#attributes' => [
'id' => 'migration-detail-source',
],
];
$migration_plugin = $this->migrationPluginManager
->createInstance($migration
->id(), $migration
->toArray());
$source = $migration_plugin
->getSourcePlugin();
$build['source']['query'] = [
'#type' => 'item',
'#title' => $this
->t('Query'),
'#markup' => '<pre>' . Xss::filterAdmin($source) . '</pre>',
];
$header = [
$this
->t('Machine name'),
$this
->t('Description'),
];
$rows = [];
foreach ($source
->fields($migration_plugin) as $machine_name => $description) {
$rows[] = [
[
'data' => Html::escape($machine_name),
],
[
'data' => Xss::filterAdmin($description),
],
];
}
$build['source']['fields'] = [
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => $this
->t('No fields'),
];
return $build;
}