File tree Expand file tree Collapse file tree 5 files changed +111
-0
lines changed
Expand file tree Collapse file tree 5 files changed +111
-0
lines changed Original file line number Diff line number Diff line change @@ -23,4 +23,5 @@ services:
2323 Prokl\BitrixOrdinaryToolsBundle\Services\Facades\ApplicationD7 : ~
2424 Prokl\BitrixOrdinaryToolsBundle\Services\Facades\CMain : ~
2525 Prokl\BitrixOrdinaryToolsBundle\Services\Facades\CUser : ~
26+ Prokl\BitrixOrdinaryToolsBundle\Services\Facades\EventMail : ~
2627
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ services:
2424
2525 Prokl\BitrixOrdinaryToolsBundle\Services\Application\BitrixGlobals : ~
2626
27+ Bitrix\Main\Mail\Event : ~
28+
2729 # $APPLICATION
2830 application.instance :
2931 class : CMain
@@ -74,3 +76,9 @@ services:
7476 - ' @event_dispatcher'
7577 - !tagged_iterator bitrix.component.event
7678
79+ # Доступ к bitrix/.settings.php.
80+ # Параметры: connections.default.host (ключи разделены точками) или connections.
81+ bx.config :
82+ class : Prokl\BitrixOrdinaryToolsBundle\Services\Utils\Config\Manager
83+
84+ Prokl\BitrixOrdinaryToolsBundle\Services\Utils\Config\Manager : ' @bx.config'
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 EventMail
9+ * @package Prokl\BitrixOrdinaryToolsBundle\Services\Facades
10+ *
11+ */
12+ class EventMail extends AbstractFacade
13+ {
14+ /**
15+ * @inheritDoc
16+ */
17+ protected static function getFacadeAccessor () : string
18+ {
19+ return 'Bitrix\Main\Mail\Event ' ;
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Prokl \BitrixOrdinaryToolsBundle \Services \Utils \Config ;
4+
5+ /**
6+ * Interface ConfigurationContract
7+ * @package Prokl\BitrixOrdinaryToolsBundle\Services\Utils\Config
8+ */
9+ interface ConfigurationContract
10+ {
11+ /**
12+ * Get config value.
13+ *
14+ * @param string $key Ключ.
15+ *
16+ * @return mixed
17+ */
18+ public function get (string $ key );
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Prokl \BitrixOrdinaryToolsBundle \Services \Utils \Config ;
4+
5+ use Bitrix \Main \Config \Configuration ;
6+
7+ /**
8+ * Class Manager
9+ * @package Prokl\BitrixOrdinaryToolsBundle\Services\Utils
10+ */
11+ class Manager implements ConfigurationContract
12+ {
13+ /**
14+ * @var Configuration|null $bxConfig
15+ */
16+ private $ bxConfig ;
17+
18+ /**
19+ * @inheritDoc
20+ */
21+ public function get (string $ key )
22+ {
23+ $ value = $ this ->getBxConfig ()->get ($ key );
24+
25+ if (!empty ($ value )) {
26+ return $ value ;
27+ }
28+
29+ $ keyPath = explode ('. ' , $ key );
30+
31+ $ root = $ this ->getBxConfig ()->get (array_shift ($ keyPath ));
32+
33+ if (empty ($ root ) || ! is_array ($ root )) {
34+ return '' ;
35+ }
36+
37+ $ current = $ root ;
38+ foreach ($ keyPath as $ key => $ val ) {
39+ if (empty ($ current [$ val ])) {
40+ return '' ;
41+ }
42+
43+ $ current = $ current [$ val ];
44+ }
45+
46+ return $ current ;
47+ }
48+
49+ /**
50+ * getBxConfig.
51+ *
52+ * @return Configuration
53+ */
54+ protected function getBxConfig ()
55+ {
56+ if (!$ this ->bxConfig ) {
57+ $ this ->bxConfig = Configuration::getInstance ();
58+ }
59+
60+ return $ this ->bxConfig ;
61+ }
62+ }
You can’t perform that action at this time.
0 commit comments