Get forge site from sites.

@param $sites
@param $site_id
@return mixed
517072
protected function getSite($sites, $site_id)
    {
        $site_found = collect($sites)->filter(function ($site) use ($site_id) {
            return $site->id === $site_id;
        })->first();

        if ($site_found) {
            return $site_found;
        }
        return null;
    }
235099
public function createForSite(SiteInterface $site)
    {
        $listRedirection = $this->redirectionRepository->findBySiteId($site->getSiteId());
        $siteLanguages = $site->getLanguages();
        $routes = array();

        foreach ($siteLanguages as $language) {
            $nodes = $this->nodeRepository->findPublishedByLanguageAndSiteId($language, $site->getSiteId());
            $routePattern = $this->nodeRepository->findAllRoutePattern($language, $site->getSiteId());
            $routePattern = $this->computeRoutePattern($routePattern);
            foreach ($nodes as $node) {
                $routes = array_merge($this->generateRoutesForNode($node, $site, $routePattern), $routes);
            }
        }

        foreach ($listRedirection as $redirection) {
            $routes = array_merge($this->generateRoutesForRedirection($redirection, $site), $routes);
        }

        return $routes;
    }
359360
protected function checkSite()
    {
        $sites = $this->fetchSites(fp_env('ACACHA_FORGE_SERVER'));
        return in_array(fp_env('ACACHA_FORGE_SITE'), collect($sites)->pluck('id')->toArray());
    }
687767
public function get(
        $root = null,
        $siteId = null,
        $pages = null,
        $pageType = null,
        $pageName = null
    ) {
        if (empty($root)) {
            $root = self::RESOURCE_SITES;
        }

        if (empty($siteId)) {
            return $root;
        }

        if (empty($pages)) {
            return $root . '.' . $siteId;
        }

        if (empty($pageType) || empty($pageName)) {
            return $root . '.' . $siteId . '.' . $pages;
        }

        return $root . '.' . $siteId . '.' . $pages . '.' . $pageType . '.' . $pageName;
    }
18757
public function getSettingBySiteId($siteId)
    {
        /** @var $query QueryBuilder */
        $params = ['dataSource' => $siteId];
        $qb     = $this->getFindByQueryBuilder($params, null, 'e', ['id','settingValue']);
        $qb->addSelect('partial k.{id,code,defaultValue}')
            ->innerJoin('e.settingKey', 'k');

        return $qb->getQuery()->getResult();
    }
161659
public static function instance($siteId, $name, array $posts)
    {
        $site = new self();

        $site->siteId = $siteId;
        $site->name   = $name;
        $site->posts  = $posts;

        return $site;
    }
347778
public function get($id)
    {
        $siteId = $this->getRequestSiteId();

        //ACCESS CHECK
        $sitePagesResource = $this->getSitePagesResourceId($siteId);
        if (!$this->isAllowed('pages', 'read')
            && !$this->isAllowed(
                $sitePagesResource,
                'read'
            )
        ) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }

        $site = $this->getSite($siteId);

        if (empty($site)) {
            return new ApiJsonModel(
                null,
                1,
                "Site was not found with id {$siteId}."
            );
        }

        $page = $this->getPage($site, $id);

        if (empty($page)) {
            return new ApiJsonModel(
                null,
                404,
                "Page was not found with id {$id}."
            );
        }

        $apiResponse = new SitePageApiResponse($page);

        return new ApiJsonModel($apiResponse, 0, 'Success');
    }
750884
public function actionGetAllUrls(array $criteria = [], $siteId = null): Response
    {
        return $this->asJson(RouteMap::$plugin->routes->getAllUrls($criteria, $siteId));
    }
268250
public function getShowBySiteID($site, $ID){
		$site = strtolower($site);
		$url = self::APIURL.'/lookup/shows?'.$site.'='.$ID;
		$show = $this->getFile($url);

		return new TVShow($show);
	}
970958
public static function getRootPageIdsFromSites(array $sites): array
    {
        $rootPageIds = [];
        foreach ($sites as $site) {
            $rootPageIds[] = (int)$site->getRootPageId();
        }

        return $rootPageIds;
    }
131104
protected function waitForSiteByName($site_name)
    {
        return $this->retry(50, function () use ($site_name) {
            $this->sites = $this->fetchSites(fp_env('ACACHA_FORGE_SERVER'));
            $site = $this->getSiteByName($this->sites, $site_name);
            return $site ? $site : null;
        });
    }
424826
public function getSitesFromIds($idSites, $limit = false)
    {
        if (count($idSites) === 0) {
            return array();
        }

        if ($limit) {
            $limit = "LIMIT " . (int)$limit;
        } else {
            $limit = '';
        }

        $idSites = array_map('intval', $idSites);

        $db    = $this->getDb();
        $sites = $db->fetchAll("SELECT * FROM " . $this->table . "
                                WHERE idsite IN (" . implode(", ", $idSites) . ")
                                ORDER BY idsite ASC $limit");

        return $sites;
    }
1023917
public function copySiteById(
        $siteId,
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON
    ) {
        /** @var \Rcm\Entity\Site $site */
        $existingSite = $this->find($siteId);

        if (empty($existingSite)) {
            throw new SiteNotFoundException("Site {$siteId} not found.");
        }

        $site = $existingSite->newInstance(
            $createdByUserId,
            $createdReason
        );

        return $site;
    }
1160711
public function getDriveBySite($siteId)
    {
        $siteLocator  = "/sites/$siteId";
        $driveLocator = '/drive';
        $endpoint     = "$siteLocator$driveLocator";

        $response = $this
            ->graph
            ->createRequest('GET', $endpoint)
            ->execute();

        $status = $response->getStatus();

        if ($status != 200) {
            throw new \Exception();
        }

        $drive = $response->getResponseAsObject(Model\Drive::class);

        return new DriveProxy($this->graph, $drive);
    }
1204352
public function findBySite($siteId)
    {
        $qb = $this->createQueryBuilder();
        $qb->field('siteId')->equals($siteId);

        return $qb;
    }
911504
public function getSiteDetails($siteId)
    {
        if ($this->connector->getURL() === null) {
            return 'Cannot find site URL from configuration.';
        }
        $url = $this->connector->getURL().self::VERSION.$siteId;
        $params = [];
        $response = $this->connector->connecting($url, $params, 'GET');

        return $response;
    }
34733
protected function getSiteByName($sites, $site_name)
    {
        $site_found = collect($sites)->filter(function ($site) use ($site_name) {
            return $site->name === $site_name;
        })->first();

        if ($site_found) {
            return $site_found;
        }
        return null;
    }