Returns all projects by server id

@param int $serverId Server if of Gerrit server
@return array
163641
protected function getGerritProjectsByServerId($serverId)
    {
        $dbHandle = $this->getDatabase()->getDatabaseConnection();

        $query = 'SELECT `id`, `name` FROM ' . Database::TABLE_PROJECT . '
                  WHERE `server_id` = :server_id';
        $statement = $dbHandle->prepare($query);

        $statement->bindParam(':server_id', $serverId, \PDO::PARAM_INT);
        $executeResult = $statement->execute();

        $statement = $this->getDatabase()->checkQueryError($statement, $executeResult);
        return $statement->fetchAll(\PDO::FETCH_ASSOC);
    }
661616
public function git($projectId)
    {
        $project = $this->fetchProject($projectId, array('local', 'remote'));
        $branch = $this->getParam('branch', $project->getBranch());
        $commit = $this->getParam('commit');
        $commitMessage = $this->getParam('message');
        $committer = $this->getParam('committer');
        $rebuild = $this->getParam('rebuild') ?? false;

        return $this->createBuild($project, $commit, $branch, $committer, $commitMessage, $rebuild);
    }
667481
public function getSiteWidePluginsList($siteId)
    {
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select('partial site.{siteId}, plugins')
            ->from(\Rcm\Entity\Site::class, 'site')
            ->join('site.sitePlugins', 'plugins')
            ->where('site.siteId = :siteId')
            ->setParameter('siteId', $siteId);

        $result = $queryBuilder->getQuery()->getSingleResult(
            \Doctrine\ORM\Query::HYDRATE_ARRAY
        );

        if (empty($result) || empty($result['sitePlugins'])) {
            return [];
        }

        return $result['sitePlugins'];
    }
59361
public function gitlab($projectId)
    {
        $project = $this->fetchProject($projectId, 'gitlab');

        $payloadString = file_get_contents("php://input");
        $payload = json_decode($payloadString, true);

        // build on merge request events
        if (isset($payload['object_kind']) && $payload['object_kind'] == 'merge_request') {
            $attributes = $payload['object_attributes'];
            if ($attributes['state'] == 'opened' || $attributes['state'] == 'reopened') {
                $branch = $attributes['source_branch'];
                $commit = $attributes['last_commit'];
                $committer = $commit['author']['email'];

                return $this->createBuild($project, $commit['id'], $branch, $committer, $commit['message']);
            }
        }

        // build on push events
        if (isset($payload['commits']) && is_array($payload['commits'])) {
            // If we have a list of commits, then add them all as builds to be tested:

            $results = array();
            $status = 'failed';
            foreach ($payload['commits'] as $commit) {
                try {
                    $branch = str_replace('refs/heads/', '', $payload['ref']);
                    $committer = $commit['author']['email'];
                    $results[$commit['id']] = $this->createBuild(
                        $project,
                        $commit['id'],
                        $branch,
                        $committer,
                        $commit['message']
                    );
                    $status = 'ok';
                } catch (Exception $ex) {
                    $results[$commit['id']] = array('status' => 'failed', 'error' => $ex->getMessage());
                }
            }
            return array('status' => $status, 'commits' => $results);
        }

        return array('status' => 'ignored', 'message' => 'Unusable payload.');
    }
963758
protected function getRepositoriesInternal($repositoryId = null)
    {
        $repositoryUrlCache = $this->getRepositoryUrlCache();

        if ($repositoryId === null) {
            // no repository id provided -> get all
            $url = $repositoryUrlCache->buildUrl($this->getServiceUrl());
        } else {
            // use URL of the specified repository
            $url = $repositoryUrlCache->getRepositoryUrl($repositoryId, Constants::SELECTOR_REPOSITORY_INFO) ??
                $repositoryUrlCache->buildUrl($this->getServiceUrl());
        }

        $repositoryInfos = [];
        $result = $this->readJson($url);
        if (!is_array($result)) {
            throw new CmisConnectionException(
                'Could not fetch repository info! Response is not a valid JSON.',
                1416343166
            );
        }
        foreach ($result as $item) {
            if (is_array($item)) {
                $repositoryInfo = $this->getJsonConverter()->convertRepositoryInfo($item);

                if ($repositoryInfo instanceof RepositoryInfoBrowserBinding) {
                    $id = $repositoryInfo->getId();
                    $repositoryUrl = $repositoryInfo->getRepositoryUrl();
                    $rootUrl = $repositoryInfo->getRootUrl();

                    if (empty($id) || empty($repositoryUrl) || empty($rootUrl)) {
                        throw new CmisConnectionException(
                            sprintf('Found invalid Repository Info! (id: %s)', $id),
                            1415187765
                        );
                    }

                    $this->getRepositoryUrlCache()->addRepository($id, $repositoryUrl, $rootUrl);

                    $repositoryInfos[] = $repositoryInfo;
                }
            } else {
                throw new CmisConnectionException(
                    sprintf(
                        'Found invalid repository info! Value of type "array" was expected'
                        . 'but value of type "%s" was given.',
                        gettype($item)
                    ),
                    1415187764
                );
            }
        }

        return $repositoryInfos;
    }
696745
public function findAllByEntityId($entityId)
    {

        // prepare the params
        $params = array(ParamNames::ENTITY_ID => $entityId);

        // load and return the customer varchar attributes with the passed entity ID
        $this->customerVarcharsStmt->execute($params);
        return $this->customerVarcharsStmt->fetchAll(\PDO::FETCH_ASSOC);
    }
418002
public function getAllLocationIds($contentId)
    {
        try {
            return $this->innerGateway->getAllLocationIds($contentId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
853246
public function certificates($serverId, $siteId)
    {
        return $this->transformCollection(
            $this->get("servers/$serverId/sites/$siteId/certificates")['certificates'],
            Certificate::class,
            ['server_id' => $serverId, 'site_id' => $siteId]
        );
    }
1069242
public List<GitlabProject> getProjects() {
        String tailUrl = GitlabProject.URL + PARAM_MAX_ITEMS_PER_PAGE;
        return retrieve().getAll(tailUrl, GitlabProject[].class);
    }
620320
public function getWebserviceHost(string $serverId)
    {
        if (!$this->hasServerConfiguration($serverId)) {
            return null;
        }

        return $this->configuration['connections'][$serverId]['host'];
    }
428381
public function read($reportID) {
        $result = $this->api->request(
            'cmdb.reports',
            [
                'id' => $reportID
            ]
        );

        if (!is_array($result)) {
            return [];
        }

        return $result;
    }
969942
public function getLastBuildByStatus($projectId = null, $status = Build::STATUS_SUCCESS)
    {
        $query = 'SELECT * FROM build WHERE project_id = :pid AND status = :status ORDER BY id DESC LIMIT 1';
        $stmt = Database::getConnection('read')->prepare($query);
        $stmt->bindValue(':pid', $projectId);
        $stmt->bindValue(':status', $status);

        if ($stmt->execute()) {
            if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
                return new Build($data);
            }
        } else {
            return array();
        }
    }
42589
public function findByProcessingId($processingId)
    {
        $handlers = [];

        $builder = $this->connection->createQueryBuilder();

        $builder->select('*')->from(Tables::MESSAGE_HANDLER)
            ->where($builder->expr()->eq('processing_id', ':processing_id'))
            ->setParameter('processing_id', $processingId);

        foreach($builder->execute() as $row) {
            $this->fromDatabase($row);
            array_push($handlers, $row);
        }

        return $handlers;
    }
1284953
public function getProject($id, $host = null, $refresh = null)
    {
        // Find the project in the user's main project list. This uses a
        // separate cache.
        $projects = $this->getProjects($refresh);
        if (isset($projects[$id])) {
            return $projects[$id];
        }

        // Find the project directly.
        $cacheKey = sprintf('%s:project:%s:%s', $this->sessionId, $id, $host);
        $cached = $this->cache->fetch($cacheKey);
        if ($refresh || !$cached) {
            $scheme = 'https';
            if ($host !== null && (($pos = strpos($host, '//')) !== false)) {
                $scheme = parse_url($host, PHP_URL_SCHEME);
                $host = substr($host, $pos + 2);
            }
            $project = $this->getClient()
                ->getProject($id, $host, $scheme !== 'http');
            if ($project) {
                $toCache = $project->getData();
                $toCache['_endpoint'] = $project->getUri(true);
                $this->cache->save($cacheKey, $toCache, $this->config->get('api.projects_ttl'));
            }
        } else {
            $guzzleClient = $this->getHttpClient();
            $baseUrl = $cached['_endpoint'];
            unset($cached['_endpoint']);
            $project = new Project($cached, $baseUrl, $guzzleClient);
        }

        return $project;
    }
238328
public function getLeaves($rootId = null): Collection
    {
        $list = $this->repo->pushCriteria(new GetLeaves($rootId))
            ->all([
                'id',
                'pid',
                'root_id',
                'deep',
                'name'
            ]);

        return $list;
    }
1045221
public function getProject(int $projectId)
    {
        if ( ! $this->validateId($projectId)) {
            return false;
        }

        $result = $this->get('projects/' . $projectId);

        if (200 === $result->getStatusCode()) {
            return json_decode($result->getBody()->getContents());
        }

        return false;
    }
888606
public function findByProject($projectId, $params = array(), $options = array())
    {
        $path = sprintf("/projects/%s/tasks", $projectId);
        return $this->client->getCollection($path, $params, $options);
    }