• Модуль: messageservice
  • Путь к файлу: ~/bitrix/modules/messageservice/lib/Providers/Base/Registrar.php
  • Класс: BitrixMessageServiceProvidersBaseRegistrar
  • Вызов: Registrar::getHostUrl
public function getHostUrl(): string
{
	$protocol = (Context::getCurrent()->getRequest()->isHttps() ? 'https' : 'http');
	if (defined("SITE_SERVER_NAME") && SITE_SERVER_NAME)
	{
		$host = SITE_SERVER_NAME;
	}
	else
	{
		$host =
			BitrixMainConfigOption::get('main', 'server_name', Context::getCurrent()->getServer()->getHttpHost())
				?: Context::getCurrent()->getServer()->getHttpHost()
		;
	}

	$port = Context::getCurrent()->getServer()->getServerPort();
	if($port != 80 && $port != 443 && $port > 0 && mb_strpos($host, ':') === false)
	{
		$host .= ':'.$port;
	}
	elseif($protocol === 'http' && $port == 80)
	{
		$host = str_replace(':80', '', $host);
	}
	elseif($protocol === 'https' && $port == 443)
	{
		$host = str_replace(':443', '', $host);
	}

	return $protocol . '://' . $host;
}