$results[$cmd] = $commandData; } } if (!empty($results)) { $apiResponse = new APIViewData(0, $deployment, false); $apiResponse->setExtraResponseData('commands', $results); $apiResponse->printJson(); } else { $apiResponse = new APIViewData(1, $deployment, "Unable to detect command(s) specified: {$command}"); $app->halt(404, $apiResponse->returnJson()); } } else { if ($commonMerge == 1) { $commandData = RevDeploy::getCommonMergedDeploymentCommand($deployment, $command, $deployRev); } else { $commandData = RevDeploy::getDeploymentCommand($deployment, $command, $deployRev); } if ($commandData !== false) { $apiResponse = new APIViewData(0, $deployment, false); $apiResponse->setExtraResponseData('command', $commandData); $apiResponse->printJson(); } else { $apiResponse = new APIViewData(1, $deployment, "Unable to detect command specified: {$command}"); $app->halt(404, $apiResponse->returnJson()); } } })->name('saigon-api-get-command'); $app->delete('/sapi/command/:deployment/:command', function ($deployment, $command) use($app) { check_deployment_exists($app, $deployment); check_auth($app, $deployment); check_revision_status($deployment);
/** * copyToStage * * @access public * @return void */ public function copyToStage() { $viewData = new ViewData(); $deployment = $this->getDeployment('command_error'); $command = $this->getParam('cmdName'); if ($command === false) { $viewData->header = $this->getErrorHeader('command_error'); $viewData->error = 'Unable to detect command specified in post params'; $this->sendError('generic_error', $viewData); } $revision = RevDeploy::getDeploymentNextRev($deployment); $commandInfo = RevDeploy::getDeploymentCommand($deployment, $command, $revision); if (empty($commandInfo)) { $viewData->header = $this->getErrorHeader('command_error'); $viewData->error = 'Unable to fetch command information for ' . $command . ' from data store'; $this->sendError('generic_error', $viewData); } $viewData->availdeployments = $this->getDeploymentsAvailToUser(); $viewData->deployment = $deployment; $viewData->command = $command; $viewData->commandInfo = $commandInfo; $viewData->action = 'copyToWrite'; $this->sendResponse('command_action_stage', $viewData); }