Returns the current site if defined.

@param  Site|null $site Optional, if provided, will be return.

@return Site|null
774294
private function getCurrentSite(Site $site = null)
    {
        if (null !== $site) {
            return $site;
        }

        if (null !== $this->application) {
            return $this->application->getSite();
        }

        return null;
    }
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;
    }
1295886
public static function getByLanguage($language, Site $site = null)
    {
        if (!$site) {
            $site = \Core::make('site')->getSite();
        }

        $em = Database::get()->getEntityManager();
        /**
         * @var $section Locale
         */
        $section = $em->getRepository('Concrete\Core\Entity\Site\Locale')
            ->findOneBy(['site' => $site, 'msLanguage' => $language]);

        if (is_object($section)) {
            $obj = parent::getByID($section->getSiteTree()->getSiteHomePageID(), 'RECENT');
            $obj->setLocale($section);

            return $obj;
        }

        return false;
    }
486940
public function getWebsite()
        {
            return isset($this->_data[self::PROFILE][self::WEBSITE]) ? $this->_data[self::PROFILE][self::WEBSITE] : null;
        }
227881
private function getUriForSite($pathinfo, Site $site = null)
    {
        $siteUsed = $this->getCurrentSite($site);
        if (null === $siteUsed || null === $this->application) {
            return $pathinfo;
        }

        $protocol = '';
        if (null === parse_url($siteUsed->getServerName(), PHP_URL_SCHEME)) {
            $protocol = (string) $this->defaultScheme;
            $protocol = $protocol . ($protocol ? ':' : '') . '//';
        }

        return $protocol . $siteUsed->getServerName() . $pathinfo;
    }
620073
protected function getPriority(ReadNodeInterface $node, ReadSiteInterface $site)
    {
        $sitemapPriority = $node->getSitemapPriority();

        if (is_null($sitemapPriority)) {
            $sitemapPriority = $site->getSitemapPriority();
        }

        return $sitemapPriority;
    }
43932
public function getResourceUrl($pathinfo, Site $site = null)
    {
        return $this->getUri($pathinfo, null, $site, RouteCollection::RESOURCE_URL);
    }
801226
public function getSite()
    {
        if ($this->site === false) {
            $this->site = $this->app->make('site')->getDefault();
        }

        return $this->site;
    }
111871
public function evaluate()
    {
        $node = $this->getNode();
        if ($node instanceof NodeInterface) {
            $contentContext = $node->getContext();
            if ($contentContext instanceof \Neos\Neos\Domain\Service\ContentContext) {
                $site = $contentContext->getCurrentSite();
                $siteConfiguration = $this->siteConfigurationRepository->findOneBySite($site);

                return $siteConfiguration;
            }
        }

        return null;
    }
771859
public function getCurrentSiteNode()
    {
        if ($this->currentSite !== null && $this->currentSiteNode === null) {
            $siteNodePath = NodePaths::addNodePathSegment(SiteService::SITES_ROOT_PATH, $this->currentSite->getNodeName());
            $this->currentSiteNode = $this->getNode($siteNodePath);
            if (!($this->currentSiteNode instanceof NodeInterface)) {
                $this->systemLogger->warning(sprintf('Couldn\'t load the site node for path "%s" in workspace "%s". This is probably due to a missing baseworkspace for the workspace of the current user.', $siteNodePath, $this->workspaceName), LogEnvironment::fromMethodName(__METHOD__));
            }
        }
        return $this->currentSiteNode;
    }
719778
protected function getSiteId($sites, $site_name)
    {
        if ($site = $this->getSiteByName($sites, $site_name)) {
            return $site->id;
        }
        return null;
    }
187039
public function tenant(Website $website = null): ?Website
    {
        if ($website !== null) {
            $this->app->instance(Tenant::class, $website);

            $this->emitEvent(new Events\Websites\Switched($website));

            return $website;
        }

        return $this->app->make(Tenant::class);
    }
410288
public function hasSite(Site $site)
    {
        return $this->sites()
            ->where(SiteModel::ATTR_ID, '=', $site->getId())
            ->exists();
    }
577569
public static function site(string $site, string $uri = null): string
    {
        $otherSite = Application::getConfig('sites')->get($site);

        if ($otherSite === null) {
            throw new Exception("Unable to construct URL to site={$site}, site is not defined in configs/sites.php");
        }

        if ($uri === null || strlen($uri) === 0) {
            return $otherSite;
        } else {
            if ($uri[0] != '/') {
                $uri = '/' . $uri;
            }

            return $otherSite . $uri;
        }
    }
1000837
protected function getSite()
    {
        $currentSite = $this->session->get(self::KEY_SITE);

        if (!$currentSite || (is_integer($currentSite['siteId']) && $currentSite['siteId'] == 0)) {
            $sites = $this->getAvailableSites();
            if (count($sites) > 0) {
                $site = array_shift($sites);
                $siteId = $site->getSiteId();
                $siteName = $site->getName();
                $locale = $site->getDefaultLanguage();
                $languages = $site->getLanguages();
                $this->setSite($siteId, $siteName, $locale, $languages);
                $currentSite = $this->session->get(self::KEY_SITE);
            }
        }

        return $currentSite;
    }
291656
public String getSiteFromAddress(String url, String site)
    {
        int iStart = url.indexOf("//") + 2;
        iStart = url.indexOf('/', iStart);
        if (iStart == -1)
            iStart = url.length();
        if ((site != null) && (site.length() > 0))
            if (!url.equalsIgnoreCase(site))
                return site; // Return this site if different from URL
        return url.substring(0, iStart);
    }
196277
public function tasks($site)
    {
        $variables = array(
            'site' => $site,
        );
        $request = $this->get(array('{+base_path}/sites/{site}/tasks.json', $variables));
        return new Response\Tasks($request);
    }