Skip to content
Snippets Groups Projects

Resolve #3498688 "Phpcs fixes"

Merged Scott Euser requested to merge issue/migrate_tools-3498688:3498688-phpcs-fixes into 6.0.x
@@ -5,6 +5,15 @@ declare(strict_types=1);
namespace Drupal\migrate_tools\Drush\Commands;
use Consolidation\OutputFormatters\StructuredData\RowsOfFields;
use Drush\Attributes\FieldLabels;
use Drush\Attributes\FilterDefaultField;
use Drush\Attributes\DefaultFields;
use Drush\Attributes\Usage;
use Drush\Attributes\ValidateModulesEnabled;
use Drush\Attributes\Topics;
use Drush\Attributes\Option;
use Drush\Attributes\Argument;
use Drush\Attributes\Command;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Component\Graph\Graph;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
@@ -21,7 +30,6 @@ use Drupal\migrate_tools\EventSubscriber\MigrationDrushCommandProgress;
use Drupal\migrate_tools\IdMapFilter;
use Drupal\migrate_tools\MigrateExecutable;
use Drupal\migrate_tools\MigrateTools;
use Drush\Attributes as CLI;
use Drush\Commands\DrushCommands;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -74,13 +82,13 @@ class MigrateToolsCommands extends DrushCommands {
*
* @command migrate:tree
*/
#[CLI\Command(name: 'migrate:tree')]
#[CLI\Argument(name: 'migration_names', description: 'Restrict to a comma-separated list of migrations (Optional).')]
#[CLI\Option(name: 'all', description: 'Process all migrations')]
#[CLI\Option(name: 'group', description: 'A comma-separated list of migration groups to import')]
#[CLI\Option(name: 'tag', description: 'A comma-separated list of migration tags to import')]
#[CLI\Topics(topics: ['migrate'])]
#[CLI\ValidateModulesEnabled(modules: ['migrate_tools'])]
#[Command(name: 'migrate:tree')]
#[Argument(name: 'migration_names', description: 'Restrict to a comma-separated list of migrations (Optional).')]
#[Option(name: 'all', description: 'Process all migrations')]
#[Option(name: 'group', description: 'A comma-separated list of migration groups to import')]
#[Option(name: 'tag', description: 'A comma-separated list of migration tags to import')]
#[Topics(topics: ['migrate'])]
#[ValidateModulesEnabled(modules: ['migrate_tools'])]
public function dependencyTree(
$migration_names = '',
array $options = [
@@ -218,25 +226,25 @@ class MigrateToolsCommands extends DrushCommands {
*
* Migrations status formatted as table.
*/
#[CLI\Command(name: 'migrate:status', aliases: ['ms', 'migrate-status'])]
#[CLI\Argument(name: 'migration_names', description: 'Restrict to a comma-separated list of migrations. Optional.')]
#[CLI\Option(name: 'group', description: 'A comma-separated list of migration groups to import')]
#[CLI\Option(name: 'tag', description: 'Name of the migration tag to list')]
#[CLI\Option(name: 'names-only', description: 'Only return names, not all the details (faster)')]
#[CLI\Option(name: 'continue-on-failure', description: 'When a migration fails, continue processing remaining migrations.')]
#[CLI\Usage(name: 'migrate:status', description: 'Retrieve status for all migrations')]
#[CLI\Usage(name: 'migrate:status --group=beer', description: 'Retrieve status for all migrations, grouped by tag')]
#[CLI\Usage(name: 'migrate:status --tag=user', description: 'Retrieve status for all migrations tagged with user.')]
#[CLI\Usage(name: 'migrate:status beer_term,beer_node', description: 'Retrieve status for specific migrations')]
#[CLI\Usage(name: 'migrate:status --field=id', description: 'Retrieve a raw list of migration IDs.')]
#[CLI\Usage(name: 'ms --fields=id,status --format=json', description: 'Retrieve a JSON serialized list of migrations, each item containing only the migration ID and its status.')]
#[CLI\Topics(topics: ['migrate'])]
#[CLI\ValidateModulesEnabled(modules: ['migrate_tools'])]
#[Command(name: 'migrate:status', aliases: ['ms', 'migrate-status'])]
#[Argument(name: 'migration_names', description: 'Restrict to a comma-separated list of migrations. Optional.')]
#[Option(name: 'group', description: 'A comma-separated list of migration groups to import')]
#[Option(name: 'tag', description: 'Name of the migration tag to list')]
#[Option(name: 'names-only', description: 'Only return names, not all the details (faster)')]
#[Option(name: 'continue-on-failure', description: 'When a migration fails, continue processing remaining migrations.')]
#[Usage(name: 'migrate:status', description: 'Retrieve status for all migrations')]
#[Usage(name: 'migrate:status --group=beer', description: 'Retrieve status for all migrations, grouped by tag')]
#[Usage(name: 'migrate:status --tag=user', description: 'Retrieve status for all migrations tagged with user.')]
#[Usage(name: 'migrate:status beer_term,beer_node', description: 'Retrieve status for specific migrations')]
#[Usage(name: 'migrate:status --field=id', description: 'Retrieve a raw list of migration IDs.')]
#[Usage(name: 'ms --fields=id,status --format=json', description: 'Retrieve a JSON serialized list of migrations, each item containing only the migration ID and its status.')]
#[Topics(topics: ['migrate'])]
#[ValidateModulesEnabled(modules: ['migrate_tools'])]
// phpcs:disable Drupal.Arrays.Array.LongLineDeclaration
#[CLI\FieldLabels(labels: ['group' => 'Group', 'id' => 'Migration ID', 'status' => 'Status', 'total' => 'Total', 'imported' => 'Imported', 'unprocessed' => 'Unprocessed', 'message_count' => 'Message Count', 'last_imported' => 'Last Imported'])] // phpcs:ignore
#[CLI\DefaultFields(fields: ['group', 'id', 'status', 'total', 'imported', 'unprocessed', 'message_count', 'last_imported'])]
#[FieldLabels(labels: ['group' => 'Group', 'id' => 'Migration ID', 'status' => 'Status', 'total' => 'Total', 'imported' => 'Imported', 'unprocessed' => 'Unprocessed', 'message_count' => 'Message Count', 'last_imported' => 'Last Imported'])] // phpcs:ignore
#[DefaultFields(fields: ['group', 'id', 'status', 'total', 'imported', 'unprocessed', 'message_count', 'last_imported'])]
// phpcs:enable
#[CLI\FilterDefaultField(field: 'status')]
#[FilterDefaultField(field: 'status')]
// phpcs:disable Drupal.Commenting.FunctionComment.Missing, Squiz.WhiteSpace.FunctionSpacing.Before
public function status(
$migration_names = '',
@@ -409,33 +417,33 @@ class MigrateToolsCommands extends DrushCommands {
* @throws \Exception
* If there are not enough parameters to the command.
*/
#[CLI\Command(name: 'migrate:import', aliases: ['mim', 'migrate-import'])]
#[CLI\Argument(name: 'migration_names', description: 'ID of migration(s) to import. Delimit multiple using commas.')]
#[CLI\Option(name: 'all', description: 'Process all migrations')]
#[CLI\Option(name: 'group', description: 'A comma-separated list of migration groups to import')]
#[CLI\Option(name: 'tag', description: 'A comma-separated list of migration tags to import')]
#[CLI\Option(name: 'limit', description: 'Limit on the number of items to process in each migration')]
#[CLI\Option(name: 'feedback', description: 'Frequency of progress messages, in items processed')]
#[CLI\Option(name: 'idlist', description: 'Comma-separated list of IDs to import.')]
#[CLI\Option(name: 'idlist-delimiter', description: 'The delimiter for records')]
#[CLI\Option(name: 'update', description: 'In addition to processing unprocessed items from the source, update previously-imported items with the current data')]
#[CLI\Option(name: 'force', description: 'Force an operation to run, even if all dependencies are not satisfied')]
#[CLI\Option(name: 'continue-on-failure', description: 'When a migration fails, continue processing remaining migrations.')]
#[CLI\Option(name: 'execute-dependencies', description: 'Execute all dependent migrations first')]
#[CLI\Option(name: 'skip-progress-bar', description: 'Skip displaying a progress bar.')]
#[CLI\Option(name: 'sync', description: 'Sync source and destination. Delete destination records that do not exist in the source.')]
#[CLI\Usage(name: 'migrate:import --all', description: 'Perform all migrations')]
#[CLI\Usage(name: 'migrate:import --group=beer', description: 'Import all migrations in the beer group')]
#[CLI\Usage(name: 'migrate:import --tag=user', description: 'Import all migrations with the user tag')]
#[CLI\Usage(name: 'migrate:import --group=beer --tag=user', description: 'Import all migrations in the beer group and with the user tag')]
#[CLI\Usage(name: 'migrate:import beer_term,beer_node', description: 'Import new terms and nodes')]
#[CLI\Usage(name: 'migrate:import beer_user --limit=2', description: 'Import no more than 2 users')]
#[CLI\Usage(name: 'migrate:import beer_user --idlist=5', description: 'Import the user record with source ID 5')]
#[CLI\Usage(name: 'migrate:import beer_node_revision --idlist=1:2,2:3,3:5', description: 'Import the node revision record with source IDs [1,2], [2,3], and [3,5]')]
#[CLI\Usage(name: 'migrate:import beer_user --limit=50 --feedback=20', description: 'Import 50 users and show process message every 20th record')]
#[CLI\Usage(name: 'migrate:import --all --sync', description: 'Perform all migrations and delete the destination items that are missing from source')]
#[CLI\Topics(topics: ['migrate'])]
#[CLI\ValidateModulesEnabled(modules: ['migrate_tools'])]
#[Command(name: 'migrate:import', aliases: ['mim', 'migrate-import'])]
#[Argument(name: 'migration_names', description: 'ID of migration(s) to import. Delimit multiple using commas.')]
#[Option(name: 'all', description: 'Process all migrations')]
#[Option(name: 'group', description: 'A comma-separated list of migration groups to import')]
#[Option(name: 'tag', description: 'A comma-separated list of migration tags to import')]
#[Option(name: 'limit', description: 'Limit on the number of items to process in each migration')]
#[Option(name: 'feedback', description: 'Frequency of progress messages, in items processed')]
#[Option(name: 'idlist', description: 'Comma-separated list of IDs to import.')]
#[Option(name: 'idlist-delimiter', description: 'The delimiter for records')]
#[Option(name: 'update', description: 'In addition to processing unprocessed items from the source, update previously-imported items with the current data')]
#[Option(name: 'force', description: 'Force an operation to run, even if all dependencies are not satisfied')]
#[Option(name: 'continue-on-failure', description: 'When a migration fails, continue processing remaining migrations.')]
#[Option(name: 'execute-dependencies', description: 'Execute all dependent migrations first')]
#[Option(name: 'skip-progress-bar', description: 'Skip displaying a progress bar.')]
#[Option(name: 'sync', description: 'Sync source and destination. Delete destination records that do not exist in the source.')]
#[Usage(name: 'migrate:import --all', description: 'Perform all migrations')]
#[Usage(name: 'migrate:import --group=beer', description: 'Import all migrations in the beer group')]
#[Usage(name: 'migrate:import --tag=user', description: 'Import all migrations with the user tag')]
#[Usage(name: 'migrate:import --group=beer --tag=user', description: 'Import all migrations in the beer group and with the user tag')]
#[Usage(name: 'migrate:import beer_term,beer_node', description: 'Import new terms and nodes')]
#[Usage(name: 'migrate:import beer_user --limit=2', description: 'Import no more than 2 users')]
#[Usage(name: 'migrate:import beer_user --idlist=5', description: 'Import the user record with source ID 5')]
#[Usage(name: 'migrate:import beer_node_revision --idlist=1:2,2:3,3:5', description: 'Import the node revision record with source IDs [1,2], [2,3], and [3,5]')]
#[Usage(name: 'migrate:import beer_user --limit=50 --feedback=20', description: 'Import 50 users and show process message every 20th record')]
#[Usage(name: 'migrate:import --all --sync', description: 'Perform all migrations and delete the destination items that are missing from source')]
#[Topics(topics: ['migrate'])]
#[ValidateModulesEnabled(modules: ['migrate_tools'])]
public function import(
$migration_names = '',
array $options = [
@@ -519,24 +527,24 @@ class MigrateToolsCommands extends DrushCommands {
* @throws \Exception
* If there are not enough parameters to the command.
*/
#[CLI\Command(name: 'migrate:rollback', aliases: ['mr', 'migrate-rollback'])]
#[CLI\Argument(name: 'migration_names', description: 'Comma-separated list of migration IDs.')]
#[CLI\Option(name: 'all', description: 'Process all migrations')]
#[CLI\Option(name: 'group', description: 'A comma-separated list of migration groups to rollback')]
#[CLI\Option(name: 'tag', description: 'ID of the migration tag to rollback')]
#[CLI\Option(name: 'feedback', description: 'Frequency of progress messages, in items processed')]
#[CLI\Option(name: 'idlist', description: 'Comma-separated list of IDs to rollback')]
#[CLI\Option(name: 'idlist-delimiter', description: 'The delimiter for records')]
#[CLI\Option(name: 'continue-on-failure', description: 'When a migration fails, continue processing remaining migrations.')]
#[CLI\Option(name: 'skip-progress-bar', description: 'Skip displaying a progress bar.')]
#[CLI\Usage(name: 'migrate:rollback --all', description: 'Rollback all migrations')]
#[CLI\Usage(name: 'migrate:rollback --group=beer', description: 'Rollback all migrations in the beer group')]
#[CLI\Usage(name: 'migrate:rollback --tag=user', description: 'Rollback all migrations tagged with user tag')]
#[CLI\Usage(name: 'migrate:rollback --group=beer --tag=user', description: 'Rollback all migrations in the beer group and with the user tag')]
#[CLI\Usage(name: 'migrate:rollback beer_term,beer_node', description: 'Rollback terms and nodes imported terms and nodes')]
#[CLI\Usage(name: 'migrate:rollback beer_user --idlist=5', description: 'Rollback imported user record with source ID 5')]
#[CLI\Topics(topics: ['migrate'])]
#[CLI\ValidateModulesEnabled(modules: ['migrate_tools'])]
#[Command(name: 'migrate:rollback', aliases: ['mr', 'migrate-rollback'])]
#[Argument(name: 'migration_names', description: 'Comma-separated list of migration IDs.')]
#[Option(name: 'all', description: 'Process all migrations')]
#[Option(name: 'group', description: 'A comma-separated list of migration groups to rollback')]
#[Option(name: 'tag', description: 'ID of the migration tag to rollback')]
#[Option(name: 'feedback', description: 'Frequency of progress messages, in items processed')]
#[Option(name: 'idlist', description: 'Comma-separated list of IDs to rollback')]
#[Option(name: 'idlist-delimiter', description: 'The delimiter for records')]
#[Option(name: 'continue-on-failure', description: 'When a migration fails, continue processing remaining migrations.')]
#[Option(name: 'skip-progress-bar', description: 'Skip displaying a progress bar.')]
#[Usage(name: 'migrate:rollback --all', description: 'Rollback all migrations')]
#[Usage(name: 'migrate:rollback --group=beer', description: 'Rollback all migrations in the beer group')]
#[Usage(name: 'migrate:rollback --tag=user', description: 'Rollback all migrations tagged with user tag')]
#[Usage(name: 'migrate:rollback --group=beer --tag=user', description: 'Rollback all migrations in the beer group and with the user tag')]
#[Usage(name: 'migrate:rollback beer_term,beer_node', description: 'Rollback terms and nodes imported terms and nodes')]
#[Usage(name: 'migrate:rollback beer_user --idlist=5', description: 'Rollback imported user record with source ID 5')]
#[Topics(topics: ['migrate'])]
#[ValidateModulesEnabled(modules: ['migrate_tools'])]
public function rollback(
$migration_names = '',
array $options = [
@@ -618,10 +626,10 @@ class MigrateToolsCommands extends DrushCommands {
* @validate-module-enabled migrate_tools
* @aliases mst, migrate-stop
*/
#[CLI\Command(name: 'migrate:stop', aliases: ['mst', 'migrate-stop'])]
#[CLI\Argument(name: 'migration_id', description: 'The ID of migration to stop.')]
#[CLI\Topics(topics: ['migrate'])]
#[CLI\ValidateModulesEnabled(modules: ['migrate_tools'])]
#[Command(name: 'migrate:stop', aliases: ['mst', 'migrate-stop'])]
#[Argument(name: 'migration_id', description: 'The ID of migration to stop.')]
#[Topics(topics: ['migrate'])]
#[ValidateModulesEnabled(modules: ['migrate_tools'])]
public function stop($migration_id): void {
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration = $this->migrationPluginManager->createInstance(
@@ -674,13 +682,13 @@ class MigrateToolsCommands extends DrushCommands {
* @validate-module-enabled migrate_tools
* @aliases mrs, migrate-reset-status
*/
#[CLI\Command(
#[Command(
name: 'migrate:reset-status',
aliases: ['mrs', 'migrate-reset-status']
)]
#[CLI\Argument(name: 'migration_id', description: 'The ID of migration to reset.')]
#[CLI\Topics(topics: ['migrate'])]
#[CLI\ValidateModulesEnabled(modules: ['migrate_tools'])]
#[Argument(name: 'migration_id', description: 'The ID of migration to reset.')]
#[Topics(topics: ['migrate'])]
#[ValidateModulesEnabled(modules: ['migrate_tools'])]
public function resetStatus($migration_id = ''): void {
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration = $this->migrationPluginManager->createInstance(
@@ -740,18 +748,18 @@ class MigrateToolsCommands extends DrushCommands {
*
* Source fields of the given migration formatted as a table.
*/
#[CLI\Command(name: 'migrate:messages', aliases: ['mmsg', 'migrate-messages'])]
#[CLI\Argument(name: 'migration_id', description: 'The ID of the migration.')]
#[CLI\Option(name: 'csv', description: 'Export messages as a CSV (deprecated)')]
#[CLI\Option(name: 'idlist', description: 'Comma-separated list of IDs to rollback')]
#[CLI\Option(name: 'idlist-delimiter', description: 'The delimiter for records')]
#[CLI\Usage(name: 'migrate:messages article', description: 'Show all messages for the <info>article</info> migration')]
#[CLI\Usage(name: 'migrate:messages node_revision --idlist=1:2,2:3,3:5', description: 'Show messages related to node revision records with source IDs [1,2], [2,3], and [3,5].')]
#[CLI\Usage(name: 'migrate:messages custom_node_revision --idlist=1:"r:1",2:"r:3"', description: 'Show messages related to node revision records with source IDs [1,"r:1"], and [2,"r:3"].')]
#[CLI\Topics(topics: ['migrate'])]
#[CLI\ValidateModulesEnabled(modules: ['migrate_tools'])]
#[Command(name: 'migrate:messages', aliases: ['mmsg', 'migrate-messages'])]
#[Argument(name: 'migration_id', description: 'The ID of the migration.')]
#[Option(name: 'csv', description: 'Export messages as a CSV (deprecated)')]
#[Option(name: 'idlist', description: 'Comma-separated list of IDs to rollback')]
#[Option(name: 'idlist-delimiter', description: 'The delimiter for records')]
#[Usage(name: 'migrate:messages article', description: 'Show all messages for the <info>article</info> migration')]
#[Usage(name: 'migrate:messages node_revision --idlist=1:2,2:3,3:5', description: 'Show messages related to node revision records with source IDs [1,2], [2,3], and [3,5].')]
#[Usage(name: 'migrate:messages custom_node_revision --idlist=1:"r:1",2:"r:3"', description: 'Show messages related to node revision records with source IDs [1,"r:1"], and [2,"r:3"].')]
#[Topics(topics: ['migrate'])]
#[ValidateModulesEnabled(modules: ['migrate_tools'])]
// phpcs:disable Drupal.Arrays.Array.LongLineDeclaration
#[CLI\FieldLabels(labels: [
#[FieldLabels(labels: [
'source_ids_hash' => 'Source IDs Hash',
'source_ids' => 'Source ID(s)',
'destination_ids' => 'Destination ID(s)',
@@ -759,7 +767,7 @@ class MigrateToolsCommands extends DrushCommands {
'message' => 'Message',
])]
// phpcs:enable
#[CLI\DefaultFields(
#[DefaultFields(
fields: [
'source_ids_hash',
'source_ids',
@@ -872,23 +880,23 @@ class MigrateToolsCommands extends DrushCommands {
* @return \Consolidation\OutputFormatters\StructuredData\RowsOfFields
* Source fields of the given migration formatted as a table.
*/
#[CLI\Command(
#[Command(
name: 'migrate:fields-source',
aliases: ['mfs', 'migrate-fields-source']
)]
#[CLI\Argument(
#[Argument(
name: 'migration_id',
description: 'The ID of the migration.'
)]
#[CLI\Topics(topics: ['migrate'])]
#[CLI\ValidateModulesEnabled(modules: ['migrate_tools'])]
#[CLI\FieldLabels(
#[Topics(topics: ['migrate'])]
#[ValidateModulesEnabled(modules: ['migrate_tools'])]
#[FieldLabels(
labels: [
'machine_name' => 'Machine Name',
'description' => 'Description',
]
)]
#[CLI\DefaultFields(fields: ['machine_name', 'description'])]
#[DefaultFields(fields: ['machine_name', 'description'])]
public function fieldsSource($migration_id): RowsOfFields {
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration = $this->migrationPluginManager->createInstance(
Loading