ClearQueueFailuresCommand.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Grav\Plugin\Console;
  3. use Grav\Common\Grav;
  4. use Grav\Console\ConsoleCommand;
  5. use Grav\Plugin\Email\Email;
  6. use Symfony\Component\Console\Input\InputOption;
  7. /**
  8. * Class FlushQueueCommand
  9. * @package Grav\Console\Cli\
  10. */
  11. class ClearQueueFailuresCommand extends ConsoleCommand
  12. {
  13. /**
  14. * @var array
  15. */
  16. protected $options = [];
  17. /**
  18. *
  19. */
  20. protected function configure()
  21. {
  22. $this
  23. ->setName('clear-queue-failures')
  24. ->setAliases(['clearqueue'])
  25. ->addOption(
  26. 'env',
  27. 'e',
  28. InputOption::VALUE_OPTIONAL,
  29. 'The environment to trigger a specific configuration. For example: localhost, mysite.dev, www.mysite.com'
  30. )
  31. ->setDescription('Clears any queue failures that have accumulated')
  32. ->setHelp('The <info>clear-queue-failures</info> command clears any queue failures that have accumulated');
  33. }
  34. /**
  35. * @return int|null|void
  36. */
  37. protected function serve()
  38. {
  39. $grav = Grav::instance();
  40. $this->output->writeln('');
  41. $this->output->writeln('<yellow>Current Configuration:</yellow>');
  42. $this->output->writeln('');
  43. dump($grav['config']->get('plugins.email'));
  44. $this->output->writeln('');
  45. require_once __DIR__ . '/../vendor/autoload.php';
  46. $output = Email::clearQueueFailures();
  47. $this->output->writeln('<green>' . $output . '</green>');
  48. }
  49. }