• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/landing/urlpreview.php
  • Класс: BitrixLandingLandingUrlPreview
  • Вызов: UrlPreview::resolveSiteId
static function resolveSiteId(string $landingPath): ?int
{
	$publicPath = Manager::getPublicationPath();

	if ($landingPath[0] !== '/')
	{
		$urlParts = parse_url($landingPath);
		$landingPath = $urlParts['path'] ?? '';
	}

	if (mb_strpos($landingPath, $publicPath) === 0)
	{
		$landingPath = mb_substr($landingPath, mb_strlen($publicPath));
		$pathChunks = explode('/', $landingPath);
		if (!empty($pathChunks[0]))
		{
			$res = Site::getList([
				'select' => [
					'ID'
				],
				'filter' => [
					'=CODE' => '/' . $pathChunks[0] . '/'
				]
			]);
			if ($row = $res->fetch())
			{
				return $row['ID'];
			}
		}
	}

	return null;
}