• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/site.php
  • Класс: BitrixMainSiteTable
  • Вызов: SiteTable::getDocumentRoot
static function getDocumentRoot($siteId = null)
{
	if ($siteId === null)
	{
		$siteId = Application::getInstance()->getContext()->getSite();
	}

	if (!isset(self::$documentRootCache[$siteId]))
	{
		$site = static::getRow([
			"filter" => ["=LID" => $siteId],
			"cache" => ["ttl" => static::CACHE_TTL],
		]);

		if ($site && ($docRoot = $site["DOC_ROOT"]) && ($docRoot <> ''))
		{
			if (!IOPath::isAbsolute($docRoot))
			{
				$docRoot = IOPath::combine(Application::getDocumentRoot(), $docRoot);
			}
			self::$documentRootCache[$siteId] = $docRoot;
		}
		else
		{
			self::$documentRootCache[$siteId] = Application::getDocumentRoot();
		}
	}

	return self::$documentRootCache[$siteId];
}