From 15d514003288c4ce162ab32009b55599ba4148d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Mon, 15 Jan 2024 17:01:59 +0300 Subject: [PATCH] Move config to di instead of di-web --- config/{di-web.php => di.php} | 7 ++++++- config/params.php | 2 ++ tests/ConfigTest.php | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) rename config/{di-web.php => di.php} (89%) diff --git a/config/di-web.php b/config/di.php similarity index 89% rename from config/di-web.php rename to config/di.php index e370ad4..8d5440b 100644 --- a/config/di-web.php +++ b/config/di.php @@ -57,9 +57,14 @@ $assetManager = $assetManager ->withConverter($container->get(AssetConverterInterface::class)) - ->withPublisher($container->get(AssetPublisherInterface::class)) ; + if ($params['yiisoft/assets']['assetManager']['publisher'] !== null) { + $assetManager = $assetManager->withPublisher( + $container->get($params['yiisoft/assets']['assetManager']['publisher']) + ); + }; + $assetManager->registerMany($params['yiisoft/assets']['assetManager']['register']); return $assetManager; }, diff --git a/config/params.php b/config/params.php index fed5ce8..d8b7c7d 100644 --- a/config/params.php +++ b/config/params.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Yiisoft\Assets\AssetLoaderInterface; +use Yiisoft\Assets\AssetPublisherInterface; use Yiisoft\Assets\Debug\AssetCollector; use Yiisoft\Assets\Debug\AssetLoaderInterfaceProxy; @@ -28,6 +29,7 @@ 'allowedBundleNames' => [], 'customizedBundles' => [], 'register' => [], + 'publisher' => AssetPublisherInterface::class, ], ], diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index c547c6d..e225420 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -50,7 +50,7 @@ private function getDiConfig(?array $params = null): array if ($params === null) { $params = $this->getParams(); } - return require dirname(__DIR__) . '/config/di-web.php'; + return require dirname(__DIR__) . '/config/di.php'; } private function getParams(): array