diff --git a/src/Commands/LegacyCommands.php b/src/Commands/LegacyCommands.php index 12b9dfd51e..ba4c24ffec 100644 --- a/src/Commands/LegacyCommands.php +++ b/src/Commands/LegacyCommands.php @@ -1,115 +1,151 @@ logger()->notice($msg); + $this->legacyFailureMessage('pm-disable'); } /** + * The pm-info command was deprecated. Please see `drush pm-list` and `composer show` + * * @command pm-info * @aliases pmi + * @allow-additional-options * @hidden */ public function info() { - $msg = 'The pm-info command was deprecated. Please see `drush pm-list` and `composer show`'; - $this->logger()->notice($msg); + $this->legacyFailureMessage('pm-info'); } /** + * The pm-projectinfo command was deprecated. Please see `drush pm-list` and `composer show` + * * @command pm-projectinfo + * @allow-additional-options * @hidden */ public function projectInfo() { - $msg = 'The pm-projectinfo command was deprecated. Please see `drush pm-list` and `composer show`'; - $this->logger()->notice($msg); + $this->legacyFailureMessage('pm-projectinfo'); } /** + * The pm-refresh command was deprecated. It is no longer useful. + * * @command pm-refresh * @aliases rf + * @allow-additional-options * @hidden */ public function refresh() { - $msg = 'The pm-refresh command was deprecated. It is no longer useful.'; - $this->logger()->notice($msg); + $this->legacyFailureMessage('pm-refresh'); } /** + * The pm-updatestatus command was deprecated. Please see `composer show` and `composer outdated`. For security release notification, your project should depend on https://github.com/drupal-composer/drupal-security-advisories. + * * @command pm-updatestatus * @aliases ups + * @allow-additional-options * @hidden */ public function updatestatus() { - $msg = 'The pm-updatestatus command was deprecated. Please see `composer show` and `composer outdated`. For security release notification, your project should depend on https://github.com/drupal-composer/drupal-security-advisories.'; - $this->logger()->notice($msg); + $this->legacyFailureMessage('pm-updatestatus'); } /** + * The pm-updatecode command was deprecated. Please see `composer outdated` and `composer update`. For security release notification, your project should depend on https://github.com/drupal-composer/drupal-security-advisories. + * * @command pm-updatecode * @aliases pm-update,upc + * @allow-additional-options * @hidden */ public function updatecode() { - $msg = 'The pm-updatecode command was deprecated. Please see `composer outdated` and `composer update`. For security release notification, your project should depend on https://github.com/drupal-composer/drupal-security-advisories.'; - $this->logger()->notice($msg); + $this->legacyFailureMessage('pm-updatecode'); } /** + * The pm-releasenotes command was deprecated. No replacement available. + * * @command pm-releasenotes * @aliases rln + * @allow-additional-options * @hidden */ public function releaseNotes() { - $msg = 'The pm-releasenotes command was deprecated. No replacement available.'; - $this->logger()->notice($msg); + $this->legacyFailureMessage('pm-releasenotes'); } /** + * The pm-releases command was deprecated. Please see `composer show ` + * * @command pm-releases * @aliases rl + * @allow-additional-options * @hidden */ public function releases() { - $msg = 'The pm-releases command was deprecated. Please see `composer show `'; - $this->logger()->notice($msg); + $this->legacyFailureMessage('pm-releases'); } /** + * Make has been removed, in favor of Composer. Use the make-convert command in Drush 8 to quickly upgrade your build to Composer. + * * @command make * @aliases make-convert,make-generate,make-lock,make-update + * @allow-additional-options * @hidden */ public function make() { - $msg = 'Make has been removed, in favor of Composer. Use the make-convert command in Drush 8 to quickly upgrade your build to Composer.'; - $this->logger()->notice($msg); + $this->legacyFailureMessage('make'); } /** + * dl has been deprecated. Please build your site using Composer. Add new projects with composer require drupal/[project-name]. Use https://www.drupal.org/project/composer_generate to build a composer.json which represents the the enabled modules on your site. + * * @command pm-download * @aliases dl + * @allow-additional-options * @hidden */ public function download() { - $msg = 'dl has been deprecated. Please build your site using Composer. Add new projects with composer require drupal/[project-name]. Use https://www.drupal.org/project/composer_generate to build a composer.json which represents the the enabled modules on your site.'; - $this->logger()->notice($msg); + $this->legacyFailureMessage('pm-download'); + } + + /** + * Throw and exception taken from the description of the legacy command. + * + * @param string $commandName + * @throws \Exception + */ + public function legacyFailureMessage($commandName) + { + $application = Drush::getApplication(); + $command = $application->get($commandName); + $message = $command->getDescription(); + throw new \Exception($message); } }