44 if (!isset(self::$documentRootCache[$siteId]))
46 $site = static::getRow([
47 "filter" => [
"=LID" => $siteId],
48 "cache" => [
"ttl" => static::CACHE_TTL],
51 if ($site && ($docRoot = $site[
"DOC_ROOT"]) && ($docRoot <>
''))
53 if (!
IO\Path::isAbsolute($docRoot))
57 self::$documentRootCache[$siteId] = $docRoot;
65 return self::$documentRootCache[$siteId];
77 'data_type' =>
'string',
81 'data_type' =>
'string',
82 'expression' => array(
'%s',
'LID'),
85 'data_type' =>
'integer',
88 'data_type' =>
'boolean',
89 'values' => array(
'N',
'Y'),
92 'data_type' =>
'boolean',
93 'values' => array(
'N',
'Y'),
96 'data_type' =>
'string'
99 'data_type' =>
'string'
101 'LANGUAGE_ID' => array(
102 'data_type' =>
'string',
105 'data_type' =>
'string',
107 'DOMAIN_LIMITED' => array(
108 'data_type' =>
'boolean',
109 'values' => array(
'N',
'Y'),
111 'SERVER_NAME' => array(
112 'data_type' =>
'string'
114 'SITE_NAME' => array(
115 'data_type' =>
'string'
118 'data_type' =>
'string'
120 'CULTURE_ID' => array(
121 'data_type' =>
'integer',
124 'data_type' =>
'Bitrix\Main\Localization\Culture',
125 'reference' => array(
'=this.CULTURE_ID' =>
'ref.ID'),
126 'join_type' =>
'INNER',
129 'data_type' =>
'Bitrix\Main\Localization\Language',
130 'reference' => array(
'=this.LANGUAGE_ID' =>
'ref.ID'),
131 'join_type' =>
'INNER',
134 (
new Fields\
ExpressionField(
'DOC_ROOT_LENGTH',
'IFNULL(LENGTH(%s), 0)',
'DOC_ROOT')),
138 public static function getByDomain(
string $host,
string $directory)
142 $sites = static::getList([
144 'filter' => [
'=ACTIVE' =>
'Y'],
146 'DIR_LENGTH' =>
'DESC',
147 'DOMAIN_LIMITED' =>
'DESC',
150 'cache' => [
'ttl' => static::CACHE_TTL],
153 $result = SiteDomainTable::getList([
154 'select' => [
'LD_LID' =>
'LID',
'LD_DOMAIN' =>
'DOMAIN'],
155 'order' => [
'DOMAIN_LENGTH' =>
'DESC'],
156 'cache' => [
'ttl' => static::CACHE_TTL],
160 while ($row = $result->fetch())
162 $domains[$row[
'LD_LID']][] = $row;
166 foreach ($sites as $row)
171 if (array_key_exists($row[
'LID'], $domains))
173 foreach ($domains[$row[
'LID']] as $dom)
176 if (strcasecmp(mb_substr(
".".$host, -mb_strlen(
"." . $dom[
'LD_DOMAIN'])),
"." . $dom[
'LD_DOMAIN']) == 0)
178 $join[] = $row + $dom;
185 $join[] = $row + [
'LD_LID' =>
'',
'LD_DOMAIN' =>
''];
190 foreach ($join as $row)
193 if ($row[
'LD_LID'] !=
'' || strcasecmp(mb_substr($directory, 0, mb_strlen($row[
'DIR'])), $row[
'DIR']) == 0)
199 foreach ($rows as $row)
202 (strcasecmp(mb_substr($directory, 0, mb_strlen($row[
'DIR'])), $row[
'DIR']) == 0)
203 && (($row[
'DOMAIN_LIMITED'] ==
'Y' && $row[
'LD_LID'] !=
'') || $row[
'DOMAIN_LIMITED'] !=
'Y')
213 foreach ($rows as $row)
215 if (strncasecmp($directory, $row[
'DIR'], mb_strlen($directory)) == 0)
225 foreach ($rows as $row)
227 if (($row[
'DOMAIN_LIMITED'] ==
'Y' && $row[
'LD_LID'] !=
'') || $row[
'DOMAIN_LIMITED'] !=
'Y')
235 if ($site ===
null && !empty($rows))
242 $site = static::getList([
244 'filter' => [
'=ACTIVE' =>
'Y'],
249 'cache' => [
'ttl' => static::CACHE_TTL],
256 unset($site[
'LD_LID'], $site[
'LD_DOMAIN']);
264 parent::cleanCache();
265 self::$documentRootCache = [];
static getByDomain(string $host, string $directory)
static getDocumentRoot($siteId=null)
static $documentRootCache