55use Bitrix \Main \ArgumentNullException ;
66use Bitrix \Main \ArgumentOutOfRangeException ;
77use Bitrix \Main \EventManager ;
8- use ProklUng \Module \Boilerplate \Options \ModuleManager ;
9- use Proklung \Symfony \Router \Router ;
108use Proklung \Symfony \Router \Subscribers \OnAfterSaveOptionsHandler ;
119use Proklung \Symfony \Router \Subscribers \ValidatorNativeConfigs ;
1210use Proklung \Symfony \Router \Subscribers \ValidatorSymfonyConfigs ;
2018class Bootstrap
2119{
2220 /**
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- *
4821 * @return void
4922 * @throws ArgumentNullException | ArgumentOutOfRangeException Ошибки аргументов модуля.
5023 */
5124 public function init () : void
5225 {
5326 $ 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+ }
5635 }
5736
5837 /**
@@ -63,10 +42,10 @@ public function init() : void
6342 */
6443 private function initSymfonyRoutes () : void
6544 {
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 ' );
6847
69- $ this -> symfonyRouterInstance = Loader::from ($ configFilePath , $ cachePath );
48+ Loader::from ($ configFilePath , $ cachePath );
7049 }
7150
7251 /**
@@ -78,36 +57,38 @@ private function initSymfonyRoutes() : void
7857 private function initNativeBitrixRoutes () : void
7958 {
8059 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 ' );
8463
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 );
8867 }
8968 }
9069 }
9170
9271 /**
72+ * Инициализация событий модуля.
73+ *
9374 * @return void
9475 */
9576 private function initEvents () : void
9677 {
9778 EventManager::getInstance ()->addEventHandler (
98- $ this -> moduleManager -> getModuleId (),
79+ OptionsManager:: moduleId (),
9980 'OnAfterSaveOptions ' ,
10081 [new OnAfterSaveOptionsHandler , 'handler ' ]
10182 );
10283
10384 EventManager::getInstance ()->addEventHandler (
104- $ this -> moduleManager -> getModuleId (),
85+ OptionsManager:: moduleId (),
10586 'OnBeforeSetOption ' ,
10687 [new ValidatorNativeConfigs , 'handler ' ]
10788 );
10889
10990 EventManager::getInstance ()->addEventHandler (
110- $ this -> moduleManager -> getModuleId (),
91+ OptionsManager:: moduleId (),
11192 'OnBeforeSetOption ' ,
11293 [new ValidatorSymfonyConfigs , 'handler ' ]
11394 );
0 commit comments