class MigrationController in Migrate Tools 8.2
Same name and namespace in other branches
- 8.5 src/Controller/MigrationController.php \Drupal\migrate_tools\Controller\MigrationController
- 8.3 src/Controller/MigrationController.php \Drupal\migrate_tools\Controller\MigrationController
- 8.4 src/Controller/MigrationController.php \Drupal\migrate_tools\Controller\MigrationController
Returns responses for migrate_tools migration view routes.
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements ContainerInjectionInterface uses LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\migrate_tools\Controller\MigrationController implements ContainerInjectionInterface
Expanded class hierarchy of MigrationController
File
- src/
Controller/ MigrationController.php, line 16
Namespace
Drupal\migrate_tools\ControllerView source
class MigrationController extends ControllerBase implements ContainerInjectionInterface {
/**
* Plugin manager for migration plugins.
*
* @var \Drupal\migrate_plus\Plugin\MigrationConfigEntityPluginManager
*/
protected $migrationConfigEntityPluginManager;
/**
* Constructs a new MigrationController object.
*
* @param \Drupal\migrate_plus\Plugin\MigrationConfigEntityPluginManager $migration_config_entity_plugin_manager
* The plugin manager for config entity-based migrations.
*/
public function __construct(MigrationConfigEntityPluginManager $migration_config_entity_plugin_manager) {
$this->migrationConfigEntityPluginManager = $migration_config_entity_plugin_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('plugin.manager.config_entity_migration'));
}
/**
* Displays an overview of a migration entity.
*
* @param string $migration_group
* Machine name of the migration's group.
* @param string $migration
* Machine name of the migration.
*
* @return array
* A render array as expected by drupal_render().
*/
public function overview($migration_group, $migration) {
/** @var MigrationInterface $migration */
$migration = $this->migrationConfigEntityPluginManager
->createInstance($migration);
$build['overview'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Overview'),
];
$build['overview']['group'] = [
'#title' => $this
->t('Group:'),
'#markup' => Xss::filterAdmin($migration_group),
'#type' => 'item',
];
$build['overview']['description'] = [
'#title' => $this
->t('Description:'),
'#markup' => Xss::filterAdmin($migration
->label()),
'#type' => 'item',
];
$migration_dependencies = $migration
->getMigrationDependencies();
if (!empty($migration_dependencies['required'])) {
$build['overview']['dependencies'] = [
'#title' => $this
->t('Migration Dependencies'),
'#markup' => Xss::filterAdmin(implode(', ', $migration_dependencies['required'])),
'#type' => 'item',
];
}
if (!empty($migration_dependencies['optional'])) {
$build['overview']['soft_dependencies'] = [
'#title' => $this
->t('Soft Migration Dependencies'),
'#markup' => Xss::filterAdmin(implode(', ', $migration_dependencies['optional'])),
'#type' => 'item',
];
}
return $build;
}
/**
* Display source information of a migration entity.
*
* @param string $migration_group
* Machine name of the migration's group.
* @param string $migration
* Machine name of the migration.
*
* @return array
* A render array as expected by drupal_render().
*/
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;
}
/**
* Display process information of a migration entity.
*
* @param string $migration_group
* Machine name of the migration's group.
* @param string $migration
* Machine name of the migration.
*
* @return array
* A render array as expected by drupal_render().
*/
public function process($migration_group, $migration) {
/** @var MigrationInterface $migration */
$migration = $this->migrationConfigEntityPluginManager
->createInstance($migration);
// 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
->getProcess() as $destination_id => $process_line) {
$row = [];
$row[] = [
'data' => Html::escape($destination_id),
];
if (isset($process_line[0]['source'])) {
$row[] = [
'data' => Xss::filterAdmin($process_line[0]['source']),
];
}
else {
$row[] = '';
}
if (isset($process_line[0]['plugin'])) {
$row[] = [
'data' => Xss::filterAdmin($process_line[0]['plugin']),
];
}
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.'),
];
return $build;
}
/**
* Displays destination information of a migration entity.
*
* @param string $migration_group
* Machine name of the migration's group.
* @param string $migration
* Machine name of the migration.
*
* @return array
* A render array as expected by drupal_render().
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ControllerBase:: |
protected | property | The configuration factory. | |
ControllerBase:: |
protected | property | The current user service. | 1 |
ControllerBase:: |
protected | property | The entity form builder. | |
ControllerBase:: |
protected | property | The entity manager. | |
ControllerBase:: |
protected | property | The entity type manager. | |
ControllerBase:: |
protected | property | The form builder. | 2 |
ControllerBase:: |
protected | property | The key-value storage. | 1 |
ControllerBase:: |
protected | property | The language manager. | 1 |
ControllerBase:: |
protected | property | The module handler. | 2 |
ControllerBase:: |
protected | property | The state service. | |
ControllerBase:: |
protected | function | Returns the requested cache bin. | |
ControllerBase:: |
protected | function | Retrieves a configuration object. | |
ControllerBase:: |
private | function | Returns the service container. | |
ControllerBase:: |
protected | function | Returns the current user. | 1 |
ControllerBase:: |
protected | function | Retrieves the entity form builder. | |
ControllerBase:: |
protected | function | Retrieves the entity manager service. | |
ControllerBase:: |
protected | function | Retrieves the entity type manager. | |
ControllerBase:: |
protected | function | Returns the form builder service. | 2 |
ControllerBase:: |
protected | function | Returns a key/value storage collection. | 1 |
ControllerBase:: |
protected | function | Returns the language manager service. | 1 |
ControllerBase:: |
protected | function | Returns the module handler. | 2 |
ControllerBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
ControllerBase:: |
protected | function | Returns the state storage service. | |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
MigrationController:: |
protected | property | Plugin manager for migration plugins. | |
MigrationController:: |
public static | function |
Instantiates a new instance of this class. Overrides ControllerBase:: |
|
MigrationController:: |
public | function | Displays destination information of a migration entity. | |
MigrationController:: |
public | function | Displays an overview of a migration entity. | |
MigrationController:: |
public | function | Display process information of a migration entity. | |
MigrationController:: |
public | function | Display source information of a migration entity. | |
MigrationController:: |
public | function | Constructs a new MigrationController object. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |