33namespace Prokl \ServiceProvider \Services ;
44
55use Bitrix \Main \Application ;
6- use Bitrix \Main \SystemException ;
76use Prokl \ServiceProvider \Bundles \BundlesLoader ;
87use LogicException ;
98use Symfony \Component \Config \Loader \LoaderInterface ;
@@ -27,6 +26,11 @@ class AppKernel extends Kernel
2726 */
2827 protected $ environment ;
2928
29+ /**
30+ * @var string $bundlesConfigFile Файл с конфигурацией бандлов.
31+ */
32+ protected $ bundlesConfigFile = '/local/configs/bundles.php ' ;
33+
3034 /**
3135 * @var boolean $debug Отладка? Оно же служит для определения типа окружения.
3236 */
@@ -51,7 +55,7 @@ public function __construct(string $environment, bool $debug)
5155
5256 parent ::__construct ($ this ->environment , $ this ->debug );
5357
54- $ this ->registerStandaloneBundles (); // "Standalone" бандлы.
58+ $ this ->bundles = $ this -> registerStandaloneBundles (); // "Standalone" бандлы.
5559 }
5660
5761 /**
@@ -162,33 +166,18 @@ public function setContainer(?ContainerInterface $container = null) : void
162166 $ this ->container = $ container ;
163167 }
164168
165- /**
166- * Хост сайта.
167- *
168- * @return string
169- *
170- * @since 08.10.2020
171- */
172- private function getSiteHost () : string
173- {
174- return $ this ->getSchema () . $ _SERVER ['HTTP_HOST ' ];
175- }
176-
177169 /**
178170 * REQUEST_URI.
179171 *
180172 * @return string
181173 *
182- * @throws SystemException Битриксовые ошибки.
183- *
184174 * @since 16.10.2020
185175 */
186176 public function getRequestUri () : string
187177 {
188178 $ request = Application::getInstance ()->getContext ()->getRequest ();
189- $ uriString = $ request ->getRequestUri ();
190179
191- return ! empty ( $ uriString ) ? $ uriString : '' ;
180+ return ( string ) $ request -> getRequestUri () ;
192181 }
193182
194183 /**
@@ -204,10 +193,12 @@ public function registerContainerConfiguration(LoaderInterface $loader)
204193 * @return iterable|BundleInterface[]
205194 *
206195 * @since 02.06.2021 Если файл не существует - игнорим.
196+ *
197+ * @internal пока не используется. Манипуляции с бандлами - через класс BundlesLoader.
207198 */
208199 public function registerBundles (): iterable
209200 {
210- $ bundleConfigPath = $ this ->getProjectDir () . ' /local/configs/bundles.php ' ;
201+ $ bundleConfigPath = $ this ->getProjectDir () . $ this -> bundlesConfigFile ;
211202
212203 if (!@file_exists ($ bundleConfigPath )) {
213204 return [];
@@ -229,6 +220,7 @@ public function registerBundles(): iterable
229220 * @param object $bundle Бандл.
230221 *
231222 * @return void
223+ * @throws LogicException Когда проскакивают дубликаты бандлов.
232224 */
233225 public function registerBundle ($ bundle ) : void
234226 {
@@ -243,15 +235,31 @@ public function registerBundle($bundle) : void
243235 /**
244236 * Регистрация "отдельностоящих" бандлов.
245237 *
246- * @return void
238+ * @return array
247239 *
248240 * @since 25.10.2020
249241 */
250- public function registerStandaloneBundles (): void
242+ public function registerStandaloneBundles (): array
251243 {
252- foreach (BundlesLoader::getBundlesMap () as $ bundle ) {
244+ $ bundles = BundlesLoader::getBundlesMap ();
245+
246+ foreach ($ bundles as $ bundle ) {
253247 $ this ->registerBundle ($ bundle );
254248 }
249+
250+ return $ bundles ;
251+ }
252+
253+ /**
254+ * Хост сайта.
255+ *
256+ * @return string
257+ *
258+ * @since 08.10.2020
259+ */
260+ private function getSiteHost () : string
261+ {
262+ return $ this ->getSchema () . $ _SERVER ['HTTP_HOST ' ];
255263 }
256264
257265 /**
0 commit comments