/** * Implement this by setting $obj values (e.g. $obj->setId($row->Id) from a DB row * @param GD_Model_Project $obj * @param Zend_Db_Table_Row_Abstract $row */ protected function populateObjectFromRow(&$obj, Zend_Db_Table_Row_Abstract $row) { $obj->setId($row->id)->setName($row->name)->setSlug($row->slug)->setRepositoryTypesId($row->repository_types_id)->setRepositoryUrl($row->repository_url)->setDeploymentBranch($row->deployment_branch)->setSSHKeysId($row->ssh_keys_id); $pk_map = new GD_Model_SSHKeysMapper(); $public_key = new GD_Model_SSHKey(); $pk_map->populateObjectFromRow($public_key, $row->findParentRow('GD_Model_DbTable_SSHKeys')); $obj->setSSHKey($public_key); }
public function indexAction() { $this->view->headLink()->appendStylesheet("/css/template/form.css"); $this->view->headLink()->appendStylesheet("/css/template/table.css"); $this->view->headLink()->appendStylesheet("/css/pages/project_settings.css"); $projects = new GD_Model_ProjectsMapper(); $project_slug = $this->_getParam("project"); if ($project_slug != "new") { $this->view->headTitle('Edit Project'); $project = $projects->getProjectBySlug($project_slug); $new_project = false; } else { $this->view->headTitle('Add Project'); $project = new GD_Model_Project(); $project->setName("New Project"); $project->setDeploymentBranch('master'); // Usually default for git // Load the ssh key $ssh_keys_map = new GD_Model_SSHKeysMapper(); $ssh_keys = new GD_Model_SSHKey(); $ssh_keys_map->find(1, $ssh_keys); $project->setSSHKey($ssh_keys); $new_project = true; } $this->view->project = $project; $this->view->new_project = $new_project; // Populate list of servers for this project if ($project->getId() > 0) { $servers = new GD_Model_ServersMapper(); $this->view->servers = $servers->getServersByProject($project->getId()); } $form = new GDApp_Form_ProjectSettings($project, null, $new_project); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getParams())) { $result = $this->saveProject($projects, $project, $new_project, $this->_getParam("errored") == "true"); if ($result !== true) { $form->repositoryUrl->addError("Could not clone the git repository [" . $result . "]. Please check the URL is correct and try again."); } else { $this->_redirect($this->getFrontController()->getBaseUrl() . "project/" . $project->getSlug() . '/settings'); } } } else { if (!$new_project) { $git = new GD_Git($project); try { $git->checkValidRepository(); $this->view->valid_repository = true; } catch (GD_Exception $ex) { $this->view->valid_repository = false; $form->repositoryUrl->addError("Check this git repository URL - is it correct?"); GD_Debug::Log("Reclone required for {$project->getName()} (project settings)", GD_Debug::DEBUG_BASIC); } } $data = array('name' => $project->getName(), 'repositoryUrl' => $project->getRepositoryUrl(), 'deploymentBranch' => $project->getDeploymentBranch(), 'publicKey' => $project->getSSHKey()->getPublicKey()); $form->populate($data); } }