File tree Expand file tree Collapse file tree 4 files changed +88
-37
lines changed
Expand file tree Collapse file tree 4 files changed +88
-37
lines changed Original file line number Diff line number Diff line change @@ -22,22 +22,27 @@ services:
2222 bitrix_ordinary_tools.cmain :
2323 class : CMain
2424
25- bitrix_ordinary_tools.application_d7 :
26- factory : ['Bitrix\Main\Application', 'getInstance']
25+ Prokl\BitrixOrdinaryToolsBundle\Services\Application\BitrixGlobals : ~
26+
27+ # $APPLICATION
28+ application.instance :
2729 class : CMain
30+ factory : ['@Prokl\BitrixOrdinaryToolsBundle\Services\Application\BitrixGlobals', 'instance']
31+
32+ bitrix_ordinary_tools.application_d7 :
33+ factory : ['@Prokl\BitrixOrdinaryToolsBundle\Services\Application\BitrixGlobals', 'instanceD7']
34+ class : Bitrix\Main\Application
35+
36+ # Битриксовый EventManager
37+ bitrix_ordinary_tools.event_manager :
38+ factory : ['@Prokl\BitrixOrdinaryToolsBundle\Services\Application\BitrixGlobals', 'eventManager']
39+ class : Bitrix\Main\EventManager
2840
2941 # Битриксовый кэшер
3042 bitrix_ordinary_tools.bitrix_cacher :
3143 public : false
3244 class : CPHPCache
3345
34- Prokl\BitrixOrdinaryToolsBundle\Services\Application\GetApplication : ~
35-
36- # $APPLICATION
37- application.instance :
38- class : CMain
39- factory : ['@Prokl\BitrixOrdinaryToolsBundle\Services\Application\GetApplication', 'instance']
40-
4146 # Обертка над CFile.
4247 bitrix_ordinary_tools.cfile_wrapper :
4348 class : Prokl\BitrixOrdinaryToolsBundle\Services\Utils\CFileWrapper
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Prokl \BitrixOrdinaryToolsBundle \Services \Application ;
4+
5+ use Bitrix \Main \Application ;
6+ use Bitrix \Main \EventManager ;
7+ use CMain ;
8+ use RuntimeException ;
9+
10+ /**
11+ * Class BitrixGlobals
12+ * $APPLICATION для инжекции в сервисы и контроллеры.
13+ * @package Prokl\BitrixOrdinaryToolsBundle\Services\Application
14+ *
15+ * @since 11.10.2020
16+ */
17+ class BitrixGlobals
18+ {
19+ /**
20+ * $APPLICATION.
21+ *
22+ * @return CMain
23+ * @throws RuntimeException
24+ */
25+ public function instance () : CMain
26+ {
27+ if (empty ($ GLOBALS ['APPLICATION ' ])) {
28+ throw new RuntimeException ('Bitrix is not initialized. ' );
29+ }
30+
31+ return $ GLOBALS ['APPLICATION ' ];
32+ }
33+
34+ /**
35+ * Инстанц Application D7.
36+ *
37+ * @return Application
38+ */
39+ public function instanceD7 () : Application
40+ {
41+ return Application::getInstance ();
42+ }
43+
44+ /**
45+ * EventManager.
46+ *
47+ * @return EventManager
48+ */
49+ public function eventManager () : EventManager
50+ {
51+ return EventManager::getInstance ();
52+ }
53+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Prokl \BitrixOrdinaryToolsBundle \Services \Facades ;
4+
5+ use Prokl \FacadeBundle \Services \AbstractFacade ;
6+
7+ /**
8+ * Class EventManager
9+ * @package Prokl\BitrixOrdinaryToolsBundle\Services\Facades
10+ *
11+ */
12+ class EventManager extends AbstractFacade
13+ {
14+ /**
15+ * @inheritDoc
16+ */
17+ protected static function getFacadeAccessor () : string
18+ {
19+ return 'bitrix_ordinary_tools.event_manager ' ;
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments