DNRoot::abortDeploy PHP Method

abortDeploy() public method

Deprecation: 2.0.0 - moved to DeployDispatcher
public abortDeploy ( SS_HTTPRequest $request ) : string
$request SS_HTTPRequest
return string
    public function abortDeploy(\SS_HTTPRequest $request)
    {
        $params = $request->params();
        $deployment = DNDeployment::get()->byId($params['Identifier']);
        if (!$deployment || !$deployment->ID) {
            throw new SS_HTTPResponse_Exception('Deployment not found', 404);
        }
        if (!$deployment->canView()) {
            return Security::permissionFailure();
        }
        // For now restrict to ADMINs only.
        if (!Permission::check('ADMIN')) {
            return Security::permissionFailure();
        }
        $environment = $deployment->Environment();
        $project = $environment->Project();
        if ($environment->Name != $params['Environment']) {
            throw new LogicException("Environment in URL doesn't match this deploy");
        }
        if ($project->Name != $params['Project']) {
            throw new LogicException("Project in URL doesn't match this deploy");
        }
        if (!in_array($deployment->Status, ['Queued', 'Deploying', 'Aborting'])) {
            throw new LogicException(sprintf("Cannot abort from %s state.", $deployment->Status));
        }
        $deployment->getMachine()->apply(DNDeployment::TR_ABORT);
        return $this->sendResponse($deployment->ResqueStatus(), []);
    }