1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
domainby.php
См. документацию.
1<?php
2
3namespace Bitrix\Landing\Site\Update;
4
5use Bitrix\Landing\Internals\DomainTable;
6use Bitrix\Landing\Manager;
7use Bitrix\Main\SystemException;
8
12class DomainBy extends Update
13{
14 protected const DOMAIN_SITE_BY = '.bitrix24site.by';
15 protected const DOMAIN_SHOP_BY = '.bitrix24shop.by';
16 protected const DOMAIN_SITE_ONLINE = '.b24site.online';
17 protected const DOMAIN_SHOP_ONLINE = '.b24shop.online';
18
26 public static function update(int $siteId): bool
27 {
29 $domainId = (int)$site['DOMAIN_ID'];
30 $domainName = self::getDomainName($domainId);
31 if ($domainName !== '')
32 {
33 $isNeedSiteDomainUpdate = self::isNeedSiteDomainUpdate($domainName);
34 $isNeedShopDomainUpdate = self::isNeedShopDomainUpdate($domainName);
35 if (!$isNeedSiteDomainUpdate && !$isNeedShopDomainUpdate)
36 {
37 return true;
38 }
39
40 if ($isNeedSiteDomainUpdate && !self::updateDomain($domainId, $domainName, 'site', $site))
41 {
42 return false;
43 }
44 if ($isNeedShopDomainUpdate && !self::updateDomain($domainId, $domainName, 'shop', $site))
45 {
46 return false;
47 }
48 }
49
50 return true;
51 }
52
53 protected static function getDomainName(int $domainId): string
54 {
55 $res = DomainTable::getList([
56 'select' => [
57 'ID', 'DOMAIN',
58 ],
59 'filter' => [
60 'ID' => $domainId,
61 ],
62 ]);
63 if (($row = $res->fetch()) && isset($row['DOMAIN']))
64 {
65 return $row['DOMAIN'];
66 }
67
68 return '';
69 }
70
77 protected static function isNeedSiteDomainUpdate(string $domainName): bool
78 {
79 if (str_ends_with($domainName, self::DOMAIN_SITE_BY))
80 {
81 return true;
82 }
83
84 return false;
85 }
86
93 protected static function isNeedShopDomainUpdate(string $domainName): bool
94 {
95 if (str_ends_with($domainName, self::DOMAIN_SHOP_BY))
96 {
97 return true;
98 }
99
100 return false;
101 }
102
113 protected static function updateDomain(int $domainId, string $domainName, string $type, array $site): bool
114 {
115 try
116 {
117 $siteController = Manager::getExternalSiteController();
118 $publicUrl = Manager::getPublicationPath($site['ID']);
119 if ($siteController)
120 {
121 $prevDomainName = $domainName;
122 if ($type === 'site')
123 {
124 $domainName = str_replace(self::DOMAIN_SITE_BY, self::DOMAIN_SITE_ONLINE, $domainName);
125 }
126 if ($type === 'shop')
127 {
128 $domainName = str_replace(self::DOMAIN_SHOP_BY, self::DOMAIN_SHOP_ONLINE, $domainName);
129 }
130
131 if ($domainName && !$siteController::isDomainExists($domainName))
132 {
133 $resDomain = DomainTable::update($domainId, [
134 'DOMAIN' => $domainName,
135 'PREV_DOMAIN' => $prevDomainName,
136 ]);
137
138 $siteController::updateDomain(
139 $prevDomainName,
140 $domainName,
141 $publicUrl
142 );
143
144 return $resDomain->isSuccess();
145 }
146
147 $domainName = $siteController::addRandomDomain(
148 $publicUrl,
149 $site['TYPE'],
150 'by'
151 );
152 $resDomain = DomainTable::update($domainId, [
153 'DOMAIN' => $domainName,
154 'PREV_DOMAIN' => $prevDomainName,
155 ]);
156
157 $siteController::updateDomain(
158 $prevDomainName,
159 $domainName,
160 $publicUrl
161 );
162
163 return $resDomain->isSuccess();
164 }
165 }
166 catch (SystemException)
167 {
168 }
169
170 return false;
171 }
172}
$type
Определения options.php:106
static getPublicationPath($siteCode=null, $siteId=null, $createPubPath=false)
Определения manager.php:401
static getExternalSiteController()
Определения manager.php:1379
static isNeedSiteDomainUpdate(string $domainName)
Определения domainby.php:77
static isNeedShopDomainUpdate(string $domainName)
Определения domainby.php:93
static getDomainName(int $domainId)
Определения domainby.php:53
const DOMAIN_SITE_ONLINE
Определения domainby.php:16
static updateDomain(int $domainId, string $domainName, string $type, array $site)
Определения domainby.php:113
static update(int $siteId)
Определения domainby.php:26
const DOMAIN_SHOP_ONLINE
Определения domainby.php:17
static getId(int $siteId)
Определения update.php:18
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$siteId
Определения ajax.php:8
$site
Определения yandex_run.php:614