Skip to content

Commit

Permalink
Replace Drush annotations with attributes (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnoordsij authored Jan 9, 2024
1 parent 0cfaf5b commit 2abda82
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drush/Commands/PolicyCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace Drush\Commands;

use Consolidation\AnnotatedCommand\CommandData;
use Consolidation\AnnotatedCommand\Hooks\HookManager;
use Drush\Attributes\Hook;
use Drush\Commands\core\RsyncCommands;
use Drush\Commands\sql\SqlSyncCommands;

/**
* Edit this file to reflect your organization's needs.
Expand All @@ -13,10 +17,9 @@ class PolicyCommands extends DrushCommands {
* Prevent catastrophic braino. Note that this file has to be local to the
* machine that initiates the sql:sync command.
*
* @hook validate sql:sync
*
* @throws \Exception
*/
#[Hook(type: HookManager::ARGUMENT_VALIDATOR, target: SqlSyncCommands::SYNC)]
public function sqlSyncValidate(CommandData $commandData) {
if ($commandData->input()->getArgument('target') == '@prod') {
throw new \Exception(dt('Per !file, you may never overwrite the production database.', ['!file' => __FILE__]));
Expand All @@ -26,10 +29,9 @@ public function sqlSyncValidate(CommandData $commandData) {
/**
* Limit rsync operations to production site.
*
* @hook validate core:rsync
*
* @throws \Exception
*/
#[Hook(type: HookManager::ARGUMENT_VALIDATOR, target: RsyncCommands::RSYNC)]
public function rsyncValidate(CommandData $commandData) {
if (preg_match("/^@prod/", $commandData->input()->getArgument('target'))) {
throw new \Exception(dt('Per !file, you may never rsync to the production site.', ['!file' => __FILE__]));
Expand Down

0 comments on commit 2abda82

Please sign in to comment.