DNRoot::startDeploy PHP Method

startDeploy() public method

Deployment form submission handler.
Deprecation: 2.0.0 - moved to DeployDispatcher Initiate a DNDeployment record and redirect to it for status polling
public startDeploy ( SS_HTTPRequest $request ) : SS_HTTPResponse
$request SS_HTTPRequest
return SS_HTTPResponse
    public function startDeploy(\SS_HTTPRequest $request)
    {
        $token = SecurityToken::inst();
        // Ensure the submitted token has a value
        $submittedToken = $request->postVar(\Dispatcher::SECURITY_TOKEN_NAME);
        if (!$submittedToken) {
            return false;
        }
        // Do the actual check.
        $check = $token->check($submittedToken);
        // Ensure the CSRF Token is correct
        if (!$check) {
            // CSRF token didn't match
            return $this->httpError(400, 'Bad Request');
        }
        // Performs canView permission check by limiting visible projects
        $project = $this->getCurrentProject();
        if (!$project) {
            return $this->project404Response();
        }
        // Performs canView permission check by limiting visible projects
        $environment = $this->getCurrentEnvironment($project);
        if (!$environment) {
            return $this->environment404Response();
        }
        // Initiate the deployment
        // The extension point should pass in: Project, Environment, SelectRelease, buildName
        $this->extend('doDeploy', $project, $environment, $buildName, $data);
        // Start the deployment based on the approved strategy.
        $strategy = new DeploymentStrategy($environment);
        $strategy->fromArray($request->requestVar('strategy'));
        $deployment = $strategy->createDeployment();
        // Bypass approval by going straight to Queued.
        $deployment->getMachine()->apply(DNDeployment::TR_QUEUE);
        return json_encode(['url' => Director::absoluteBaseURL() . $deployment->Link()], JSON_PRETTY_PRINT);
    }