Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CronRemoveCommand.php
Go to the documentation of this file.
1 <?php
7 
9 use Symfony\Component\Console\Command\Command;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
14 
18 class CronRemoveCommand extends Command
19 {
23  private $crontabManager;
24 
28  public function __construct(CrontabManagerInterface $crontabManager)
29  {
30  $this->crontabManager = $crontabManager;
31 
32  parent::__construct();
33  }
34 
38  protected function configure()
39  {
40  $this->setName('cron:remove')
41  ->setDescription('Removes tasks from crontab');
42 
43  parent::configure();
44  }
45 
49  protected function execute(InputInterface $input, OutputInterface $output)
50  {
51  try {
52  $this->crontabManager->removeTasks();
53  } catch (LocalizedException $e) {
54  $output->writeln('<error>' . $e->getMessage() . '</error>');
55  return Cli::RETURN_FAILURE;
56  }
57 
58  $output->writeln('<info>Magento cron tasks have been removed</info>');
59 
60  return Cli::RETURN_SUCCESS;
61  }
62 }
__construct(CrontabManagerInterface $crontabManager)
execute(InputInterface $input, OutputInterface $output)