Ejemplo n.º 1
0
 /**
  * @param JobRegistry $registry
  */
 public function runJobs(JobRegistry $registry)
 {
     while ($registry->count() > 0) {
         $job = $registry->getNewJob();
         $this->runJob($job);
         $registry->markJobComplete($job);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param string[] $names
  *
  * @return array
  */
 public function buildJobs($names)
 {
     foreach ($names as $name) {
         $jobInfo = $this->config['jobs'][$name];
         $description = isset($jobInfo['description']) ? $jobInfo['description'] : "";
         $job = new JobDefinition($name, $description);
         foreach ($jobInfo['tasks'] as $taskInfo) {
             $task = new TaskDefinition($taskInfo['type']);
             $task->setContinueOnError(isset($taskInfo['continueOnError']) ? $taskInfo['continueOnError'] : false);
             unset($taskInfo['type'], $taskInfo['continueOnError']);
             $task->setParameters($taskInfo);
             $job->addTask($task);
         }
         $this->registry->addJob($job);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param string[] $names
  *
  * @throws \Exception
  * @return array
  */
 private function buildJobs(array $names)
 {
     $jobs = $this->container->getParameter('jobs');
     foreach ($names as $name) {
         if (!array_key_exists($name, $jobs)) {
             throw new BldrException(sprintf("Job `%s` does not exist. Found: %s", $name, implode(', ', array_keys($jobs))));
         }
         $jobInfo = $jobs[$name];
         $description = isset($jobInfo['description']) ? $jobInfo['description'] : "";
         $job = new JobDefinition($name, $description);
         foreach ($jobInfo['tasks'] as $taskInfo) {
             $task = new TaskDefinition($taskInfo['type']);
             $task->setContinueOnError(isset($taskInfo['continueOnError']) ? $taskInfo['continueOnError'] : false);
             unset($taskInfo['type'], $taskInfo['continueOnError']);
             $task->setParameters($taskInfo);
             $job->addTask($task);
         }
         $this->registry->addJob($job);
     }
 }