示例#1
0
 /**
  * @param OutputInterface $output
  * @param Schedule $schedule
  *
  * @return null|Job
  */
 protected function createJob(OutputInterface $output, Schedule $schedule)
 {
     $cron = $this->getContainer()->get('oro_cron.helper.cron')->createCron($schedule->getDefinition());
     $arguments = array_values($schedule->getArguments());
     /**
      * @todo Add "Oro timezone" setting as parameter to isDue method
      */
     if ($cron->isDue()) {
         if (!$this->hasJobInQueue($schedule->getCommand(), $arguments)) {
             $job = new Job($schedule->getCommand(), $arguments);
             $output->writeln('<comment>added to job queue</comment>');
             return $job;
         } else {
             $output->writeln('<comment>already exists in job queue</comment>');
         }
     } else {
         $output->writeln('<comment>skipped</comment>');
     }
     return null;
 }