Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Proxy.php
1<?php
3
5use CBitrix24;
6
11class Proxy
12{
13 private static array $sourceDomains = [
14 'fonts.googleapis.com',
15 ];
16
17 private static array $map = [
18 'en' => '.bitrix24.com',
19 'de' => '.bitrix24.de',
20 'fr' => '.bitrix24.fr',
21 'it' => '.bitrix24.it',
22 'pl' => '.bitrix24.pl',
23 'uk' => '.bitrix24.uk',
24 'eu' => '.bitrix24.eu',
25 'ua' => '.bitrix24.ua',
26 'tr' => '.bitrix24.com.tr',
27 'br' => '.bitrix24.com.br',
28 'ru' => '.bitrix24.ru',
29 'la' => '.bitrix24.es',
30 'kz' => '.bitrix24.kz',
31 'by' => '.bitrix24.by',
32 'jp' => '.bitrix24.jp',
33 'cn' => '.bitrix24.cn',
34 ];
35
44 public static function makeUri(string $fontUri, ?string $region = null): string
45 {
46 $uri = new Main\Web\Uri($fontUri);
47 $domain = self::getMap($region)[$uri->getHost()] ?? null;
48 if (!$domain)
49 {
50 return $fontUri;
51 }
52
53 return 'https://' . $domain . $uri->getPathQuery();
54 }
55
63 public static function resolveDomain(?string $region = null): string
64 {
65 $domain = null;
66
67 $region = $region ?: Main\Application::getInstance()->getLicense()->getRegion();
68 if (Main\Loader::includeModule('bitrix24'))
69 {
70 $domain = CBitrix24::getAreaConfig($region)['DEFAULT_DOMAIN'] ?? null;
71 }
72
73 if (!$domain)
74 {
75 $domain = self::$map[$region] ?? self::$map['en'];
76 }
77
78 return "fonts{$domain}";
79 }
80
89 public static function getMap(?string $region = null): array
90 {
91 $map = [];
92 $targetDomain = self::resolveDomain($region);
93 foreach (self::$sourceDomains as $sourceDomain)
94 {
95 $map[$sourceDomain] = $targetDomain;
96 }
97
98 return $map;
99 }
100}
101
static resolveDomain(?string $region=null)
Definition Proxy.php:63
static makeUri(string $fontUri, ?string $region=null)
Definition Proxy.php:44
static getMap(?string $region=null)
Definition Proxy.php:89