Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function addJob(JobInterface $job)
 {
     if (isset($this->jobs[$job->getId()])) {
         throw new FlowException(sprintf('The flow "%s" already contains a job with id "%s"', $this->getId(), $job->getId()));
     }
     $job->setFlow($this);
     $this->jobs[$job->getId()] = $job;
 }
 /**
  * Executes the given job.
  *
  * @param JobInterface $job
  *
  * @throws JobExecutionException If something went wrong during job execution
  */
 protected function executeJob(JobInterface $job)
 {
     $this->eventDispatcher->dispatch(FlowEvents::JOB_EXECUTION_STARTED, new JobExecutionStartedEvent($job));
     try {
         $job->execute();
     } catch (\Exception $e) {
         throw new JobExecutionException($job, sprintf('Execution of job "%s" failed', $job->getId()), 0, $e);
     }
     $this->eventDispatcher->dispatch(FlowEvents::JOB_EXECUTION_FINISHED, new JobExecutionFinishedEvent($job));
 }