3
3
namespace Drush \Commands ;
4
4
5
5
use 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 ;
6
10
7
11
/**
8
12
* Edit this file to reflect your organization's needs.
@@ -13,10 +17,9 @@ class PolicyCommands extends DrushCommands {
13
17
* Prevent catastrophic braino. Note that this file has to be local to the
14
18
* machine that initiates the sql:sync command.
15
19
*
16
- * @hook validate sql:sync
17
- *
18
20
* @throws \Exception
19
21
*/
22
+ #[Hook(type: HookManager::ARGUMENT_VALIDATOR , target: SqlSyncCommands::SYNC )]
20
23
public function sqlSyncValidate (CommandData $ commandData ) {
21
24
if ($ commandData ->input ()->getArgument ('target ' ) == '@prod ' ) {
22
25
throw new \Exception (dt ('Per !file, you may never overwrite the production database. ' , ['!file ' => __FILE__ ]));
@@ -26,10 +29,9 @@ public function sqlSyncValidate(CommandData $commandData) {
26
29
/**
27
30
* Limit rsync operations to production site.
28
31
*
29
- * @hook validate core:rsync
30
- *
31
32
* @throws \Exception
32
33
*/
34
+ #[Hook(type: HookManager::ARGUMENT_VALIDATOR , target: RsyncCommands::RSYNC )]
33
35
public function rsyncValidate (CommandData $ commandData ) {
34
36
if (preg_match ("/^@prod/ " , $ commandData ->input ()->getArgument ('target ' ))) {
35
37
throw new \Exception (dt ('Per !file, you may never rsync to the production site. ' , ['!file ' => __FILE__ ]));
0 commit comments