/** * @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); } }
/** * @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); } }