MigrateBoosterCommands.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Drupal\migrate_booster\Commands;
  3. use Consolidation\AnnotatedCommand\AnnotationData;
  4. use Drupal\migrate_booster\MigrateBooster;
  5. use Drush\Commands\DrushCommands;
  6. use Symfony\Component\Console\Input\InputInterface;
  7. /**
  8. *
  9. * In addition to a commandfile like this one, you need a drush.services.yml
  10. * in root of your module.
  11. *
  12. * See these files for an example of injecting Drupal services:
  13. * - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php
  14. * - http://cgit.drupalcode.org/devel/tree/drush.services.yml
  15. */
  16. class MigrateBoosterCommands extends DrushCommands {
  17. /**
  18. * Resets migrate booster and implementation cache.
  19. *
  20. * @command migrate:booster:reset
  21. *
  22. * @validate-module-enabled migrate_booster
  23. * @aliases mbr,migrate-booster-reset
  24. */
  25. public function boosterReset()
  26. {
  27. // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a
  28. // legacy command.
  29. MigrateBooster::reset();
  30. }
  31. /**
  32. * Enables migrate booster and implementation cache.
  33. *
  34. * @command migrate:booster:enable
  35. *
  36. * @validate-module-enabled migrate_booster
  37. * @aliases mbe,migrate-booster-enable
  38. */
  39. public function boosterEnable()
  40. {
  41. // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a
  42. // legacy command.
  43. MigrateBooster::enable();
  44. }
  45. /**
  46. * @hook init *
  47. */
  48. public function initCommand(InputInterface $input, AnnotationData $annotationData) {
  49. // Skip when bootstrap level is low (e.g. drush cr)
  50. if (!\Drupal::hasContainer()) {
  51. return;
  52. }
  53. MigrateBooster::bootDrush($input, $annotationData);
  54. }
  55. }