Created
June 21, 2019 06:20
-
-
Save bmack/5072de0e6704726191f65e32c69666cc to your computer and use it in GitHub Desktop.
TYPO3: Create an absolute URL for a page with Site Handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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