Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function add(JobInterface $job)
 {
     if (null != $this->validator) {
         $this->logger->debug('Validate job');
         $errors = $this->validator->validate($job);
         if (count($errors) > 0) {
             $this->logger->debug('Validation failed with errors', ['errors' => $errors]);
             throw new ValidationFailedException($errors);
         }
     }
     if (!$this->jobManager->isManagerOf($job)) {
         $job = $this->helper->copyJob($job, $this->jobManager->create());
     }
     $job->setStatus(Status::REQUESTED());
     $job->setProcessingTime(0);
     $this->jobManager->save($job);
     $this->logger->info(sprintf('Added job %s of type "%s"', $job->getTicket(), $job->getType()), ['parameters' => $job->getParameters(), 'schedules' => $job->getSchedules()]);
     if (!$job->hasSchedules()) {
         $this->publishJob($job);
     }
     return $job;
 }