Exemplo n.º 1
0
 private function createVirtualHost(array $params, $key, Project $project)
 {
     $vhost = new VirtualHost();
     $vhost->setName($params['name']);
     $vhost->setServerName($params['name'] . '.' . $project->getVhostName());
     $vhost->setDocumentRoot(str_replace('.platform.app.yaml', substr($params['web']['document_root'], 1), $key));
     $vhost->setDirectoryIndex(substr($params['web']['passthru'], 1));
     $vhost->setProject($project);
     return $vhost;
 }
 /**
  * Removes a project from the database.
  *
  * @param \commpress\Cli\Entity\Project $project
  *      The project to remove.
  *
  * @throws \commpress\Cli\Service\Database\Exception\DatabaseQueryException
  *      If something goes wrong.
  */
 public function removeProject(Project $project)
 {
     $query = sprintf('DELETE FROM projects WHERE %s = :id', Project::FIELD_ID);
     $stmt = $this->database->prepare($query);
     $stmt->bindValue(':' . Project::FIELD_ID, $project->getId());
     $result = $stmt->execute();
     $stmt->close();
     if (!$result) {
         throw new DatabaseQueryException(sprintf('Failed to remove project [ id: %d, acronym: %s ] from database.', $project->getId(), $project->getShortName()));
     }
 }
 /**
  * Initializes all required member variables.
  *
  * @param \commpress\Cli\Entity\Project $project
  *      The project.
  * @param $gitBranch
  *      The git branch name.
  */
 private function initialize(Project $project, $gitBranch)
 {
     $this->project = $project;
     $this->gitBranch = $gitBranch;
     $this->serverSuffix = $this->createServerSuffix($project->getShortName(), $gitBranch);
     $this->localProjectDirectory = $this->localProjectPath . '/' . $project->getShortName() . '/' . $gitBranch;
 }
 public function __construct(Project $project, $gitBranch)
 {
     parent::__construct(sprintf('Project: %s, Branch: %s', $project->getShortName(), $gitBranch));
 }
 /**
  * Creates a new Project entity and returns it.
  *
  * @param array $data
  *      The project data.
  *
  * @return \commpress\Cli\Entity\Project
  *      The new Project entity instance.
  */
 public static function buildEntity(array $data)
 {
     $project = new Project();
     if (!empty($data[Entity::FIELD_ID])) {
         $project->setId($data[Project::FIELD_ID]);
     }
     $project->setFullName($data[Project::FIELD_NAME]);
     $project->setShortName($data[Project::FIELD_SHORT_NAME]);
     $project->setGitRepositoryUrl($data[Project::FIELD_REPOSITORY_URL]);
     $project->setVhostName($data[Project::FIELD_VHOST_NAME]);
     return $project;
 }