diff --git a/src/Commands/config/ConfigCommands.php b/src/Commands/config/ConfigCommands.php index db62e4e118..bd278b3dc1 100644 --- a/src/Commands/config/ConfigCommands.php +++ b/src/Commands/config/ConfigCommands.php @@ -242,7 +242,7 @@ public function edit($config_name, $options = []): void if (!$options['bg']) { $redispatch_options = Drush::redispatchOptions() + ['strict' => 0, 'partial' => true, 'source' => $temp_dir]; $self = $this->siteAliasManager()->getSelf(); - $process = $this->processManager()->drush($self, 'config-import', [], $redispatch_options); + $process = $this->processManager()->drush($self, ConfigImportCommands::IMPORT, [], $redispatch_options); $process->mustRun($process->showRealtime()); } } diff --git a/src/Commands/config/ConfigPullCommands.php b/src/Commands/config/ConfigPullCommands.php index 529f8b2e3f..a6fdd1be4f 100644 --- a/src/Commands/config/ConfigPullCommands.php +++ b/src/Commands/config/ConfigPullCommands.php @@ -8,6 +8,7 @@ use Consolidation\AnnotatedCommand\Hooks\HookManager; use Drush\Attributes as CLI; use Drush\Commands\core\DocsCommands; +use Drush\Commands\core\RsyncCommands; use Drush\Commands\DrushCommands; use Drush\Drush; use Consolidation\SiteAlias\HostPath; @@ -45,7 +46,7 @@ public function pull(string $source, string $destination, array $options = ['saf 'format' => 'string', ]; $this->logger()->notice(dt('Starting to export configuration on :destination.', [':destination' => $destination])); - $process = $this->processManager()->drush($sourceRecord, 'config-export', [], $export_options + $global_options); + $process = $this->processManager()->drush($sourceRecord, ConfigExportCommands::EXPORT, [], $export_options + $global_options); $process->mustRun(); if ($this->getConfig()->simulate()) { @@ -77,7 +78,7 @@ public function pull(string $source, string $destination, array $options = ['saf 'delete' => true, 'exclude' => '.htaccess', ]; - $process = $this->processManager()->drush($runner, 'core-rsync', $args, ['yes' => true, 'debug' => true], $options_double_dash); + $process = $this->processManager()->drush($runner, RsyncCommands::RSYNC, $args, ['yes' => true, 'debug' => true], $options_double_dash); $process->mustRun(); return new PropertyList(['path' => $destinationHostPath->getOriginal()]); } diff --git a/src/Commands/core/BrowseCommands.php b/src/Commands/core/BrowseCommands.php index b7aea2dad9..53e20efb99 100644 --- a/src/Commands/core/BrowseCommands.php +++ b/src/Commands/core/BrowseCommands.php @@ -18,10 +18,12 @@ final class BrowseCommands extends DrushCommands implements SiteAliasManagerAwar use ExecTrait; use SiteAliasManagerAwareTrait; + const BROWSE = 'browse'; + /** * Display a link to a given path or open link in a browser. */ - #[CLI\Command(name: 'browse')] + #[CLI\Command(name: self::BROWSE)] #[CLI\Argument(name: 'path', description: 'Path to open. If omitted, the site front page will be opened.')] #[CLI\Option(name: 'browser', description: 'Open the URL in the default browser. Use --no-browser to avoid opening a browser.')] #[CLI\Option(name: 'redirect-port', description: 'The port that the web server is redirected to (e.g. when running within a Vagrant environment).')] @@ -35,7 +37,7 @@ public function browse($path = '', array $options = ['browser' => true, 'redirec // Redispatch if called against a remote-host so a browser is started on the // the *local* machine. if ($this->processManager()->hasTransport($aliasRecord)) { - $process = $this->processManager()->drush($aliasRecord, 'browse', [$path], Drush::redispatchOptions()); + $process = $this->processManager()->drush($aliasRecord, self::BROWSE, [$path], Drush::redispatchOptions()); $process->mustRun(); $link = $process->getOutput(); } else { diff --git a/src/Commands/core/CacheCommands.php b/src/Commands/core/CacheCommands.php index 2ae18bfb39..04031875c5 100644 --- a/src/Commands/core/CacheCommands.php +++ b/src/Commands/core/CacheCommands.php @@ -199,7 +199,7 @@ protected function setPrepareData($data, $options) if (is_object($data) && $data->data) { $data = $data->data; } elseif (is_array($data) && isset($data['data'])) { - // But $data returned from `drush cache-get --format=json` will be an array. + // But $data returned from `drush cache:get --format=json` will be an array. $data = $data['data']; } else { // If $data is neither object nor array and cache-get was specified, then diff --git a/src/Commands/core/CliCommands.php b/src/Commands/core/CliCommands.php index e647ababdb..e08c47fb09 100644 --- a/src/Commands/core/CliCommands.php +++ b/src/Commands/core/CliCommands.php @@ -132,12 +132,12 @@ protected function getDrushCommands(): array $ignored_commands = [ 'help', self::PHP, - 'core:cli', + CliCommands::PHP, 'php', - 'php:eval', + PhpCommands::EVAL, 'eval', 'ev', - 'php:script', + PhpCommands::SCRIPT, 'scr', ]; $php_keywords = $this->getPhpKeywords(); diff --git a/src/Commands/core/CoreCommands.php b/src/Commands/core/CoreCommands.php index 47bbbd455c..8fe92c9e26 100644 --- a/src/Commands/core/CoreCommands.php +++ b/src/Commands/core/CoreCommands.php @@ -18,11 +18,12 @@ final class CoreCommands extends DrushCommands implements SiteAliasManagerAwareI use SiteAliasManagerAwareTrait; const VERSION = 'version'; + const GLOBAL_OPTIONS = 'core:global-options'; /** * All global options. */ - #[CLI\Command(name: 'core:global-options', aliases: ['core-global-options'])] + #[CLI\Command(name: self::GLOBAL_OPTIONS, aliases: ['core-global-options'])] #[CLI\Help(hidden: true)] #[CLI\Topics(isTopic: true)] #[CLI\FieldLabels(labels: ['name' => 'Name', 'description' => 'Description'])] diff --git a/src/Commands/core/EditCommands.php b/src/Commands/core/EditCommands.php index 36e08e359b..41b52462b1 100644 --- a/src/Commands/core/EditCommands.php +++ b/src/Commands/core/EditCommands.php @@ -32,7 +32,7 @@ final class EditCommands extends DrushCommands implements SiteAliasManagerAwareI #[CLI\Usage(name: 'drush core:edit sett', description: 'Edit settings.php for the current Drupal site.')] #[CLI\Usage(name: 'drush core:edit --choice=2', description: 'Edit the second file in the choice list.')] #[CLI\Bootstrap(level: DrupalBootLevels::MAX)] - #[CLI\HookSelector(name: 'optionset_get_editor')] + #[CLI\OptionsetGetEditor] public function edit($filter = null, array $options = []): void { $all = $this->load(); diff --git a/src/Commands/core/RoleCommands.php b/src/Commands/core/RoleCommands.php index 78225952b0..a6526451cc 100644 --- a/src/Commands/core/RoleCommands.php +++ b/src/Commands/core/RoleCommands.php @@ -78,7 +78,7 @@ public function roleAddPerm($machine_name, $permissions): void $perms = StringUtils::csvToArray($permissions); user_role_grant_permissions($machine_name, $perms); $this->logger()->success(dt('Added "!permissions" to "!role"', ['!permissions' => $permissions, '!role' => $machine_name])); - $this->processManager()->drush($this->siteAliasManager()->getSelf(), 'cache:rebuild'); + $this->processManager()->drush($this->siteAliasManager()->getSelf(), CacheRebuildCommands::REBUILD); } /** @@ -97,7 +97,7 @@ public function roleRemovePerm($machine_name, $permissions): void $perms = StringUtils::csvToArray($permissions); user_role_revoke_permissions($machine_name, $perms); $this->logger()->success(dt('Removed "!permissions" to "!role"', ['!permissions' => $permissions, '!role' => $machine_name])); - $this->processManager()->drush($this->siteAliasManager()->getSelf(), 'cache:rebuild'); + $this->processManager()->drush($this->siteAliasManager()->getSelf(), CacheRebuildCommands::REBUILD); } /** diff --git a/src/Commands/sql/SqlSyncCommands.php b/src/Commands/sql/SqlSyncCommands.php index 016cf100f5..d67227d85c 100644 --- a/src/Commands/sql/SqlSyncCommands.php +++ b/src/Commands/sql/SqlSyncCommands.php @@ -7,6 +7,7 @@ use Consolidation\AnnotatedCommand\CommandData; use Consolidation\AnnotatedCommand\Hooks\HookManager; use Drush\Attributes as CLI; +use Drush\Commands\core\CoreCommands; use Drush\Commands\core\DocsCommands; use Drush\Commands\core\RsyncCommands; use Drush\Commands\core\StatusCommands; @@ -114,7 +115,7 @@ public function databaseName(SiteAlias $record): string return 'simulated_db'; } - $process = $this->processManager()->drush($record, 'core-status', [], ['fields' => 'db-name', 'format' => 'json']); + $process = $this->processManager()->drush($record, StatusCommands::STATUS, [], ['fields' => 'db-name', 'format' => 'json']); $process->setSimulated(false); $process->mustRun(); $data = $process->getOutputAsJson();