protected function setHostnamesForEncoding()
{
if ($GLOBALS['TSFE']->config['config']['typolinkEnableLinksAcrossDomains']) {
// We have to find proper domain for the id.
$pageRepository = $GLOBALS['TSFE']->sys_page;
/** @var \TYPO3\CMS\Frontend\Page\PageRepository $pageRepository */
$id = $this->urlParameters['id'];
if (!MathUtility::canBeInterpretedAsInteger($id)) {
$id = $pageRepository->getPageIdFromAlias($this->urlParameters['id']);
}
$MP = isset($this->urlParameters['MP']) ? $this->urlParameters['MP'] : '';
$rootline = $pageRepository->getRootLine($id, $MP);
$globalConfig =& $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'];
foreach ($rootline as $page) {
foreach ($globalConfig as $domainName => $configuration) {
if ($domainName !== '_DOMAINS' && is_array($configuration) && isset($configuration['pagePath']) && is_array($configuration['pagePath']) && isset($configuration['pagePath']['rootpage_id'])) {
if ((int) $configuration['pagePath']['rootpage_id'] === (int) $page['uid']) {
$this->hostName = $domainName;
break 2;
}
}
}
}
}
if (empty($this->hostName)) {
$this->alternativeHostName = $this->hostName = $this->utility->getCurrentHost();
}
}