protected function generateFromPage(PageInterface $page, array $parameters = [], $referenceType = self::ABSOLUTE_PATH)
    {
        // hybrid pages use, by definition, the default routing mechanism
        if ($page->isHybrid()) {
            return $this->router->generate($page->getRouteName(), $parameters, $referenceType);
        }

        $url = $this->getUrlFromPage($page);

        if (false === $url) {
            throw new \RuntimeException(sprintf('Page "%d" has no url or customUrl.', $page->getId()));
        }

        // NEXT_MAJOR: remove this if block
        if (!$this->context instanceof SiteRequestContextInterface) {
            @trigger_error(
                sprintf('Since, 3.3 when calling %s, %s::$context should implement SiteRequestContextInterface. This will become mandatory in 4.0.', __METHOD__, __CLASS__),
                E_USER_DEPRECATED
            );

            return $this->decorateUrl($url, $parameters, $referenceType);
        }

        // Get current site
        $currentSite = $this->context->getSite();
        // Change to new site
        $this->context->setSite($page->getSite());
        // Fetch Url
        $decoratedUrl = $this->decorateUrl($url, $parameters, $referenceType);
        // Swap back to original site
        $this->context->setSite($currentSite);

        return $decoratedUrl;
    }