33namespace Drush \Commands ;
44
55use Consolidation \AnnotatedCommand \CommandData ;
6+ use Consolidation \AnnotatedCommand \Hooks \HookManager ;
7+ use Drush \Attributes \Hook ;
8+ use Drush \Commands \core \RsyncCommands ;
9+ use Drush \Commands \sql \SqlSyncCommands ;
610
711/**
812 * Edit this file to reflect your organization's needs.
@@ -13,10 +17,9 @@ class PolicyCommands extends DrushCommands {
1317 * Prevent catastrophic braino. Note that this file has to be local to the
1418 * machine that initiates the sql:sync command.
1519 *
16- * @hook validate sql:sync
17- *
1820 * @throws \Exception
1921 */
22+ #[Hook(type: HookManager::ARGUMENT_VALIDATOR , target: SqlSyncCommands::SYNC )]
2023 public function sqlSyncValidate (CommandData $ commandData ) {
2124 if ($ commandData ->input ()->getArgument ('target ' ) == '@prod ' ) {
2225 throw new \Exception (dt ('Per !file, you may never overwrite the production database. ' , ['!file ' => __FILE__ ]));
@@ -26,10 +29,9 @@ public function sqlSyncValidate(CommandData $commandData) {
2629 /**
2730 * Limit rsync operations to production site.
2831 *
29- * @hook validate core:rsync
30- *
3132 * @throws \Exception
3233 */
34+ #[Hook(type: HookManager::ARGUMENT_VALIDATOR , target: RsyncCommands::RSYNC )]
3335 public function rsyncValidate (CommandData $ commandData ) {
3436 if (preg_match ("/^@prod/ " , $ commandData ->input ()->getArgument ('target ' ))) {
3537 throw new \Exception (dt ('Per !file, you may never rsync to the production site. ' , ['!file ' => __FILE__ ]));
0 commit comments