Skip to content

Instantly share code, notes, and snippets.

@bmack
Created June 21, 2019 06:20
Show Gist options
  • Select an option

  • Save bmack/5072de0e6704726191f65e32c69666cc to your computer and use it in GitHub Desktop.

Select an option

Save bmack/5072de0e6704726191f65e32c69666cc to your computer and use it in GitHub Desktop.

Revisions

  1. bmack created this gist Jun 21, 2019.
    14 changes: 14 additions & 0 deletions GenerateUrlWithSites.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    /**
    * 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);
    }