public function MigrationController::source in Migrate Tools 8.2
Same name and namespace in other branches
- 8.5 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
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::source'
File
- src/
Controller/ MigrationController.php, line 107
Class
- MigrationController
- Returns responses for migrate_tools migration view routes.
Namespace
Drupal\migrate_tools\ControllerCode
public function source($migration_group, $migration) {
/** @var MigrationInterface $migration */
$migration = $this->migrationConfigEntityPluginManager
->createInstance($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',
],
];
$source = $migration
->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) 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;
}