Exemple #1
0
 /**
  * Set data to JobResult
  * TODO: Find a way to work with multiple amount of job and step executions
  * TODO https://magecore.atlassian.net/browse/BAP-2600
  *
  * @param JobResult $jobResult
  * @param JobInstance $jobInstance
  */
 protected function setJobResultData(JobResult $jobResult, JobInstance $jobInstance)
 {
     $jobResult->setJobId($jobInstance->getId());
     $jobResult->setJobCode($jobInstance->getCode());
     /** @var JobExecution $jobExecution */
     $jobExecution = $jobInstance->getJobExecutions()->first();
     if ($jobExecution) {
         $stepExecutions = $jobExecution->getStepExecutions();
         /** @var StepExecution $firstStepExecution */
         $firstStepExecution = $stepExecutions->first();
         if ($firstStepExecution) {
             $context = $this->contextRegistry->getByStepExecution($firstStepExecution);
             if ($stepExecutions->count() > 1) {
                 /** @var StepExecution $stepExecution */
                 foreach ($stepExecutions->slice(1) as $stepExecution) {
                     ContextHelper::mergeContextCounters($context, $this->contextRegistry->getByStepExecution($stepExecution));
                 }
             }
             $jobResult->setContext($context);
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getJobExecutions()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getJobExecutions', array());
     return parent::getJobExecutions();
 }