Example #1
0
 /**
  * creates a mapped job from another (basically clones it)
  *
  * @param JobInterface $job         the job to clone
  * @param string       $mappedClass FQCN of the entity to map the result to
  *
  * @return self
  */
 public static function createFrom(JobInterface $job, $mappedClass, RepositoryFactoryInterface $repositoryFactory = null)
 {
     $mappedJob = new MappedJob($job->getServiceName(), $job->getRequest(), $mappedClass);
     $mappedJob->setMethod($job->getMethod());
     $mappedJob->setBody($job->getBody());
     if (null !== $repositoryFactory) {
         $mappedJob->setEntityRepository($repositoryFactory->getRepositoryForEntity($mappedClass));
     }
     return $mappedJob;
 }
Example #2
0
 public function run(JobInterface $job)
 {
     $service = $this->serviceProvider->createService($job->getServiceName());
     $result = $service->request($job->getRequest(), $job->getMethod(), $job->getBody(), $job->getAdditionalHeaders());
     $job->setResult($result);
     // allow chaining
     return $this;
 }