5
5
use Bitrix \Main \ArgumentNullException ;
6
6
use Bitrix \Main \ArgumentOutOfRangeException ;
7
7
use Bitrix \Main \EventManager ;
8
- use ProklUng \Module \Boilerplate \Options \ModuleManager ;
9
- use Proklung \Symfony \Router \Router ;
10
8
use Proklung \Symfony \Router \Subscribers \OnAfterSaveOptionsHandler ;
11
9
use Proklung \Symfony \Router \Subscribers \ValidatorNativeConfigs ;
12
10
use Proklung \Symfony \Router \Subscribers \ValidatorSymfonyConfigs ;
20
18
class Bootstrap
21
19
{
22
20
/**
23
- * @var ModuleManager $moduleManager
24
- */
25
- private $ moduleManager ;
26
-
27
- /**
28
- * @var Router|null $symfonyRouterInstance
29
- */
30
- private $ symfonyRouterInstance ;
31
-
32
- /**
33
- * @var BitrixRouteConvertor|null $bitrixRouteConvertor
34
- */
35
- private $ bitrixRouteConvertor ;
36
-
37
- /**
38
- * Bootstrap constructor.
39
- */
40
- public function __construct ()
41
- {
42
- $ this ->moduleManager = new ModuleManager ('proklung.symfony.router ' );
43
- }
44
-
45
- /**
46
- * Инициализация хозяйства.
47
- *
48
21
* @return void
49
22
* @throws ArgumentNullException | ArgumentOutOfRangeException Ошибки аргументов модуля.
50
23
*/
51
24
public function init () : void
52
25
{
53
26
$ this ->initEvents ();
54
- $ this ->initSymfonyRoutes ();
55
- $ this ->initNativeBitrixRoutes ();
27
+
28
+ if (OptionsManager::option ('symfony_routes_active ' )) {
29
+ $ this ->initSymfonyRoutes ();
30
+ }
31
+
32
+ if (OptionsManager::option ('bitrix_routes_active ' )) {
33
+ $ this ->initNativeBitrixRoutes ();
34
+ }
56
35
}
57
36
58
37
/**
@@ -63,10 +42,10 @@ public function init() : void
63
42
*/
64
43
private function initSymfonyRoutes () : void
65
44
{
66
- $ configFilePath = $ this -> moduleManager -> get ('yaml_config_file_path ' );
67
- $ cachePath = $ this -> moduleManager -> get ('yaml_cache_path ' );
45
+ $ configFilePath = OptionsManager:: option ('yaml_config_file_path ' );
46
+ $ cachePath = OptionsManager:: option ('yaml_cache_path ' );
68
47
69
- $ this -> symfonyRouterInstance = Loader::from ($ configFilePath , $ cachePath );
48
+ Loader::from ($ configFilePath , $ cachePath );
70
49
}
71
50
72
51
/**
@@ -78,36 +57,38 @@ private function initSymfonyRoutes() : void
78
57
private function initNativeBitrixRoutes () : void
79
58
{
80
59
if ($ this ->checkRequirements ()) {
81
- $ configBitrixRoutesPath = $ this -> moduleManager -> get ('native_config_file_path ' );
82
- $ cacheBitrixRoutesPath = $ this -> moduleManager -> get ('native_yaml_cache_path ' );
83
- $ phpConfigFile = $ this -> moduleManager -> get ('php_router_config_path ' );
60
+ $ configBitrixRoutesPath = OptionsManager:: option ('native_config_file_path ' );
61
+ $ cacheBitrixRoutesPath = OptionsManager:: option ('native_yaml_cache_path ' );
62
+ $ phpConfigFile = OptionsManager:: option ('php_router_config_path ' );
84
63
85
- $ this -> bitrixRouteConvertor = Loader::native ($ configBitrixRoutesPath , $ cacheBitrixRoutesPath );
86
- if ($ this -> bitrixRouteConvertor !== null ) {
87
- Loader::save ($ phpConfigFile , $ this -> bitrixRouteConvertor );
64
+ $ routeConvertor = Loader::native ($ configBitrixRoutesPath , $ cacheBitrixRoutesPath );
65
+ if ($ routeConvertor !== null ) {
66
+ Loader::save ($ phpConfigFile , $ routeConvertor );
88
67
}
89
68
}
90
69
}
91
70
92
71
/**
72
+ * Инициализация событий модуля.
73
+ *
93
74
* @return void
94
75
*/
95
76
private function initEvents () : void
96
77
{
97
78
EventManager::getInstance ()->addEventHandler (
98
- $ this -> moduleManager -> getModuleId (),
79
+ OptionsManager:: moduleId (),
99
80
'OnAfterSaveOptions ' ,
100
81
[new OnAfterSaveOptionsHandler , 'handler ' ]
101
82
);
102
83
103
84
EventManager::getInstance ()->addEventHandler (
104
- $ this -> moduleManager -> getModuleId (),
85
+ OptionsManager:: moduleId (),
105
86
'OnBeforeSetOption ' ,
106
87
[new ValidatorNativeConfigs , 'handler ' ]
107
88
);
108
89
109
90
EventManager::getInstance ()->addEventHandler (
110
- $ this -> moduleManager -> getModuleId (),
91
+ OptionsManager:: moduleId (),
111
92
'OnBeforeSetOption ' ,
112
93
[new ValidatorSymfonyConfigs , 'handler ' ]
113
94
);
0 commit comments