To create a listener you need to something similar in your class: use Bolt\Events\CronEvents; $this->app['dispatcher']->addListener(CronEvents::CRON_INTERVAL, [$this, 'myJobCallbackMethod']); CRON_INTERVAL should be replace with one of the following: * CRON_HOURLY * CRON_DAILY * CRON_WEEKLY * CRON_MONTHLY * CRON_YEARLY
Author: Gawain Lynch (gawain.lynch@gmail.com)
Inheritance: extends Symfony\Component\EventDispatcher\Event
Example #1
0
 /**
  * @see \Symfony\Component\Console\Command\Command::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('run')) {
         $event = $input->getOption('run');
         $param = ['run' => true, 'event' => $event];
     } else {
         $event = false;
         $param = ['run' => false, 'event' => ''];
     }
     $result = new Cron($this->app, $output);
     if ($result->execute($param)) {
         if ($event) {
             $this->auditLog(__CLASS__, "Cron {$event} job run");
         } else {
             $this->auditLog(__CLASS__, 'Cron run');
         }
         $output->writeln('<info>Cron run!</info>');
     }
 }