DeploymentStrategy::createDeployment PHP Method

createDeployment() public method

public createDeployment ( ) : DNDeployment
return DNDeployment
    public function createDeployment()
    {
        $deployment = \DNDeployment::create();
        $deployment->EnvironmentID = $this->environment->ID;
        $deployment->SHA = $this->getOption('sha');
        $deployment->RefType = $this->getOption('ref_type');
        $deployment->RefName = $this->getOption('ref_name');
        $deployment->Summary = $this->getOption('summary');
        $deployment->Title = $this->getOption('title');
        $deployment->Strategy = $this->toJSON();
        $deployment->DeployerID = \Member::currentUserID();
        $deployment->write();
        // re-get and return the deployment so we have the correct state
        return \DNDeployment::get()->byId($deployment->ID);
    }

Usage Example

Beispiel #1
0
 /**
  * Deployment form submission handler.
  *
  * Initiate a DNDeployment record and redirect to it for status polling
  *
  * @param SS_HTTPRequest $request
  *
  * @return SS_HTTPResponse
  * @throws ValidationException
  * @throws null
  */
 public function startDeploy(SS_HTTPRequest $request)
 {
     // Ensure the CSRF Token is correct
     if (!$this->checkCsrfToken($request)) {
         // 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();
     $deployment->start();
     return json_encode(array('url' => Director::absoluteBaseURL() . $deployment->Link()), JSON_PRETTY_PRINT);
 }
All Usage Examples Of DeploymentStrategy::createDeployment