コード例 #1
0
 /**
  * Returns the environments.
  *
  * @return Environment[]
  *      The environments.
  *
  * @throws \commpress\Cli\Service\Database\Exception\DatabaseQueryException
  *      If something goes wrong while querying the data.
  */
 public function getEnvironments()
 {
     $result = $this->database->query('SELECT * FROM ' . self::TABLE_ENVIRONMENTS);
     if (!$result) {
         throw new DatabaseQueryException('Failed to load environments from database.');
     }
     $environments = [];
     while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
         $environment = new Environment();
         // TODO: Get rid of the new operator (Builder-Pattern).
         $environment->setId($row[Environment::FIELD_ID]);
         $environment->setProjectId($row[Environment::FIELD_PROJECT_ID]);
         $environment->setBranch($row[Environment::FIELD_BRANCH]);
         $environment->setContainerIds($row[Environment::FIELD_CONTAINER_IDS]);
         $environments[] = $environment;
     }
     return $environments;
 }
コード例 #2
0
 /**
  * Returns the registered projects.
  *
  * @return Project[]
  *      The projects.
  *
  * @throws \commpress\Cli\Service\Database\Exception\DatabaseQueryException
  *      If something goes wrong while querying the data.
  */
 public function getProjects()
 {
     $result = $this->database->query('SELECT * FROM ' . self::TABLE_PROJECTS);
     if (!$result) {
         throw new DatabaseQueryException('Failed to load projects from database.');
     }
     $projects = [];
     while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
         $project = new Project();
         // TODO: Get rid of the new operator (Builder-Pattern).
         $project->setId($row[Project::FIELD_ID]);
         $project->setFullName($row[Project::FIELD_NAME]);
         $project->setShortName($row[Project::FIELD_SHORT_NAME]);
         $project->setGitRepositoryUrl($row[Project::FIELD_REPOSITORY_URL]);
         $project->setVhostName($row[Project::FIELD_VHOST_NAME]);
         $projects[] = $project;
     }
     return $projects;
 }