Skip to content

Instantly share code, notes, and snippets.

@bmack
Created June 21, 2019 06:20
Show Gist options
  • Save bmack/5072de0e6704726191f65e32c69666cc to your computer and use it in GitHub Desktop.
Save bmack/5072de0e6704726191f65e32c69666cc to your computer and use it in GitHub Desktop.
TYPO3: Create an absolute URL for a page with Site Handling
/**
* Generates an absolute URL for a page (based on Site Handling)
*
* @param int $pageId
* @param array|null $arguments
* @return UriInterface
* @throws \TYPO3\CMS\Core\Exception\SiteNotFoundException
* @throws \TYPO3\CMS\Core\Routing\InvalidRouteArgumentsException
*/
private function getUrlForPage(int $pageId, array $arguments = null): UriInterface
{
$site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageId);
return $site->getRouter()->generateUri($pageId, $arguments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment