Site/OptionalSite.php
public function getChosenSite()
    {
        $currentRequest = $this->requestStack->getCurrentRequest();

        if ($siteId = $currentRequest->get('site')) {
            if ($site = $this->getSiteById($siteId)) {
                return $site;
            }

            throw new SiteNotFoundException(sprintf("Can't find site by %s Site ID.", $siteId));
        }

        return $this->getOriginalSite();
    }
public function getChosenSite()
    {
        $currentRequest = $this->requestStack->getCurrentRequest();

        if ($siteId = $currentRequest->get('site')) {
            if ($site = $this->getSiteById($siteId)) {
                return $site;
            }

            throw new SiteNotFoundException(sprintf("Can't find site by %s Site ID.", $siteId));
        }

        return $this->getOriginalSite();
    }
{@inheritdoc}