ClearQueueFailuresCommand.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. /** @var array */
  14. protected $options = [];
  15. /**
  16. * @return void
  17. */
  18. protected function configure()
  19. {
  20. $this
  21. ->setName('clear-queue-failures')
  22. ->setAliases(['clearqueue'])
  23. ->addOption(
  24. 'env',
  25. 'e',
  26. InputOption::VALUE_OPTIONAL,
  27. 'The environment to trigger a specific configuration. For example: localhost, mysite.dev, www.mysite.com'
  28. )
  29. ->setDescription('Clears any queue failures that have accumulated')
  30. ->setHelp('The <info>clear-queue-failures</info> command clears any queue failures that have accumulated');
  31. }
  32. /**
  33. * @return int
  34. */
  35. protected function serve()
  36. {
  37. // TODO: remove when requiring Grav 1.7+
  38. if (method_exists($this, 'initializeGrav')) {
  39. $this->initializeGrav();
  40. }
  41. $this->output->writeln('');
  42. $this->output->writeln('<yellow>Current Configuration:</yellow>');
  43. $this->output->writeln('');
  44. $grav = Grav::instance();
  45. dump($grav['config']->get('plugins.email'));
  46. $this->output->writeln('');
  47. require_once __DIR__ . '/../vendor/autoload.php';
  48. Email::clearQueueFailures();
  49. return 0;
  50. }
  51. }