1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
manager.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\Store\EnableWizard;
4
5use Bitrix\Catalog\Config\State;
6use Bitrix\Main\Application;
7use Bitrix\Main\Config\Option;
8use Bitrix\Main\Loader;
9use Bitrix\Main\Result;
10use Bitrix\Main\UI\Extension;
11
13{
14 private const MODE_OPTION_NAME = 'store_control_mode';
15
16 public static function getAvailableModes(): array
17 {
18 $result = [
20 ];
21
22 if (in_array(Application::getInstance()->getLicense()->getRegion(), ['ru', 'by', 'kz'], true))
23 {
25 }
26
27 return $result;
28 }
29
30 public static function getCurrentMode(): ?string
31 {
32 if (!State::isEnabledInventoryManagement())
33 {
34 return null;
35 }
36
37 return self::getMode();
38 }
39
40 public static function isOnecMode(): bool
41 {
43 }
44
45 public static function enable(string $mode, array $options = []): Result
46 {
47 $disableResult = self::disableCurrent();
48 if (!$disableResult->isSuccess())
49 {
50 return $disableResult;
51 }
52
53 $enableResult = self::getEnabler($mode)->enable($options);
54 if ($enableResult->isSuccess())
55 {
56 self::setMode($mode);
57
58 if (Loader::includeModule('pull'))
59 {
60 \CPullWatch::AddToStack(
61 'CATALOG_INVENTORY_MANAGEMENT_CHANGED',
62 [
63 'module_id' => 'crm',
64 'command' => 'onCatalogInventoryManagementEnabled',
65 ],
66 );
67 }
68 }
69
70 return $enableResult;
71 }
72
73 public static function disable(): Result
74 {
75 $disableResult = self::disableCurrent();
76 if ($disableResult->isSuccess())
77 {
78 self::resetMode();
79
80 if (Loader::includeModule('pull'))
81 {
82 \CPullWatch::AddToStack(
83 'CATALOG_INVENTORY_MANAGEMENT_CHANGED',
84 [
85 'module_id' => 'crm',
86 'command' => 'onCatalogInventoryManagementDisabled',
87 ],
88 );
89 }
90 }
91
92 return $disableResult;
93 }
94
95 public static function showEnabledJsNotificationIfNeeded(): void
96 {
97 Extension::load(['catalog.store-enable-wizard']);
98 ?>
99 <script>
100 BX.ready(
101 function()
102 {
103 BX.Catalog.Store.EnableWizardOpener.showEnabledNotificationIfNeeded();
104 }
105 );
106 </script>
107 <?php
108 }
109
110 private static function disableCurrent(): Result
111 {
112 $currentMode = self::getCurrentMode();
113 if ($currentMode)
114 {
115 return self::getEnabler($currentMode)->disable();
116 }
117
118 return new Result();
119 }
120
121 private static function getEnabler(string $mode): Enabler
122 {
123 return match ($mode)
124 {
125 ModeList::B24 => new B24Enabler(),
126 ModeList::ONEC => new OnecEnabler(),
127 };
128 }
129
130 private static function setMode(string $mode): void
131 {
132 if (!ModeList::isValidMode($mode))
133 {
134 return;
135 }
136
137 Option::set('catalog', self::MODE_OPTION_NAME, $mode);
138 }
139
140 private static function resetMode(): void
141 {
142 Option::set('catalog', self::MODE_OPTION_NAME);
143 }
144
145 private static function getMode(): string
146 {
147 $mode = Option::get('catalog', self::MODE_OPTION_NAME);
148
149 return ModeList::isValidMode($mode) ? $mode : ModeList::B24;
150 }
151}
static enable(string $mode, array $options=[])
Определения manager.php:45
static showEnabledJsNotificationIfNeeded()
Определения manager.php:95
static getAvailableModes()
Определения manager.php:16
static isValidMode(string $mode)
Определения modelist.php:10
$options
Определения commerceml2.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14