Ejemplo n.º 1
0
 public function saveAction()
 {
     $this->request->defineParams(array('applicationId' => array('type' => 'int'), 'sourceId' => array('type' => 'int'), 'name', 'pre_deploy_script', 'post_deploy_script'));
     $application = Scalr_Dm_Application::init();
     if ($this->getParam('applicationId')) {
         $application->loadById($this->getParam('applicationId'));
         $this->user->getPermissions()->validate($application);
     } else {
         $application->envId = $this->getEnvironmentId();
     }
     $chkId = Scalr_Dm_Application::getIdByNameAndSource($this->getParam('name'), $this->getParam('sourceId'));
     if (!$this->getParam('applicationId') && $chkId || $chkId && $chkId != $this->getParam('applicationId')) {
         throw new Exception("Application already exists in database");
     }
     $application->name = $this->getParam('name');
     $application->sourceId = $this->getParam('sourceId');
     $application->setPreDeployScript($this->getParam('pre_deploy_script', true));
     $application->setPostDeployScript($this->getParam('post_deploy_script', true));
     $application->save();
     $this->response->success('Application successfully saved');
     $this->response->data(array('app' => $application));
 }
Ejemplo n.º 2
0
 public function DmApplicationCreate($Name, $SourceID, $PreDeployScript = null, $PostDeployScript = null)
 {
     $this->restrictAccess(Acl::RESOURCE_DEPLOYMENTS_APPLICATIONS);
     $application = Scalr_Model::init(Scalr_Model::DM_APPLICATION);
     $application->envId = $this->Environment->id;
     if (Scalr_Dm_Application::getIdByNameAndSource($Name, $SourceID)) {
         throw new Exception("Application already exists in database");
     }
     $application->name = $Name;
     $application->sourceId = $SourceID;
     $application->setPreDeployScript($PreDeployScript);
     $application->setPostDeployScript($PostDeployScript);
     $application->save();
     $response = $this->CreateInitialResponse();
     $response->ApplicationID = $application->id;
     return $response;
 }