PolicyCommands.php 1.0 KB

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