/**
  * Allow to validate and run the job
  *
  * @param bool        $isUpload
  * @param JobInstance $jobInstance
  *
  * @return JobInstance
  */
 protected function launchJob($isUpload, JobInstance $jobInstance)
 {
     $this->eventDispatcher->dispatch(JobProfileEvents::PRE_EXECUTE, new GenericEvent($jobInstance));
     $rawConfig = $isUpload ? addslashes(json_encode($jobInstance->getJob()->getConfiguration())) : '';
     $jobExecution = $this->simpleJobLauncher->setConfig(['email' => true])->launch($jobInstance, $this->getUser(), $rawConfig);
     $this->eventDispatcher->dispatch(JobProfileEvents::POST_EXECUTE, new GenericEvent($jobInstance));
     $this->addFlash('success', sprintf('The %s is running.', $this->getJobType()));
     return $jobExecution;
 }
 /**
  * Allow to validate and run the job
  *
  * @param bool        $isUpload
  * @param JobInstance $jobInstance
  *
  * @return JobInstance
  */
 protected function launchJob($isUpload, JobInstance $jobInstance)
 {
     $this->eventDispatcher->dispatch(JobProfileEvents::PRE_EXECUTE, new GenericEvent($jobInstance));
     $rawConfig = $isUpload ? addslashes(json_encode($jobInstance->getJob()->getConfiguration())) : '';
     $jobExecution = $this->simpleJobLauncher->setConfig(['email' => true])->launch($jobInstance, $this->tokenStorage->getToken()->getUser(), $rawConfig);
     $this->eventDispatcher->dispatch(JobProfileEvents::POST_EXECUTE, new GenericEvent($jobInstance));
     $this->request->getSession()->getFlashBag()->add('success', new Message(sprintf('flash.%s.running', $this->getJobType())));
     return $jobExecution;
 }