/** * Execute job * * @throws \RuntimeException * @return void */ public function execute() { try { $this->params['command'] = 'setup:upgrade'; $this->command->run(new ArrayInput($this->params), $this->output); $this->queue->addJobs([['name' => JobFactory::JOB_STATIC_REGENERATE, 'params' => []]]); } catch (\Exception $e) { $this->status->toggleUpdateError(true); throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage())); } }
/** * Create an update task for Updater app * * @param array $packages * @param string $type * @param array $additionalOptions * @return string */ public function createUpdaterTask(array $packages, $type, array $additionalOptions = []) { try { // write to .update_queue.json file $params = []; if (!empty($packages)) { $params['components'] = $packages; } foreach ($additionalOptions as $key => $value) { $params[$key] = $value; } $this->queue->addJobs([['name' => $type, 'params' => $params]]); return ''; } catch (\Exception $e) { return $e->getMessage(); } }
/** * Run remove component job * * @return void * @throw \RuntimeException */ public function execute() { if (!isset($this->params['components']) || !is_array($this->params['components'])) { $this->status->toggleUpdateError(true); throw new \RunTimeException('Job parameter format is incorrect'); } $components = $this->params['components']; foreach ($components as $component) { $this->executeComponent($component); } $this->queue->addJobs([['name' => JobFactory::JOB_STATIC_REGENERATE, 'params' => []]]); $errorMessage = $this->updater->createUpdaterTask($components, Updater::TASK_TYPE_UNINSTALL); if ($errorMessage) { $this->status->toggleUpdateError(true); throw new \RuntimeException($errorMessage); } }
/** * @expectedException \RuntimeException * @expectedExceptionMessage field is missing for one or more jobs */ public function testAddJobsInvalidJobs() { $this->queue->addJobs([['no_name' => 'no job', 'no_params' => []]]); }