public function postCleanup(SyrupJob $job) { $this->logger->debug('PostCleanup start'); if (!$job) { $this->logger->debug('Any job given for postCleanup'); return; } $command = $job->getCommand(); try { // run jobu if ($command === 'run') { $esJob = new Job(); $esJob->build($job); if (!$this->usePhases($esJob)) { $executor = new Cleanup($this->orchestrationManager, $this->jobManagerFactory, $this->mailer, $this->encryptor, $this->logger, $this->queueFactory); } else { $executor = new CleanupParallel($this->orchestrationManager, $this->jobManagerFactory, $this->mailer, $this->encryptor, $this->logger, $this->queueFactory); } $executor->setStorageApi($this->storageApi); $executor->postCleanup($job); return; } } catch (\Exception $e) { $this->logger->error('PostCleanup error', array('exception' => $e)); throw $e; } throw new \InvalidArgumentException(sprintf('Executor cannot clenaup "%s" jobs.', $command)); }
public function execute(Job $job) { $command = $job->getCommand(); $params = $job->getParams(); if (!method_exists($this, $command)) { throw new ApplicationException(sprintf("Unknown command '%s'", $command)); } return $this->{$command}($params); }
/** * @param Job $job * @return array * @throws ApplicationException */ public function execute(Job $job) { $params = $job->getParams(); $command = $job->getCommand(); switch ($command) { case 'create': $response = $this->createWorkspace($params); break; case 'delete': $response = $this->deleteWorkspace($params); break; default: throw new ApplicationException("Unknown command {$command}"); } return $response; }