From 60434ee1c918b6e6b3c5a8c59e16270ce7374aa2 Mon Sep 17 00:00:00 2001 From: juniwalk Date: Thu, 3 Feb 2022 10:40:08 +0100 Subject: [PATCH 1/2] Convert config into object if it is not already --- src/DI/TessaExtension.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/DI/TessaExtension.php b/src/DI/TessaExtension.php index 7423fd2..bec5b3c 100644 --- a/src/DI/TessaExtension.php +++ b/src/DI/TessaExtension.php @@ -15,6 +15,7 @@ use Nette\DI\CompilerExtension; use Nette\Schema\Expect; use Nette\Schema\Schema; +use Nette\Utils\ArrayHash; final class TessaExtension extends CompilerExtension { @@ -48,6 +49,10 @@ public function loadConfiguration() $builder = $this->getContainerBuilder(); $config = $this->getConfig(); + if (!is_object($config)) { + $config = ArrayHash::from($config); + } + $storage = $builder->addDefinition($this->prefix('storage')) ->setFactory(Storage::class, [$config->outputDir]) ->addSetup('setCheckLastModified', [$config->checkLastModified]) From 65d65a4a63b82b5e2aa6e579fb1cb1ee86684aea Mon Sep 17 00:00:00 2001 From: juniwalk Date: Thu, 3 Feb 2022 10:47:47 +0100 Subject: [PATCH 2/2] Added defaults for older php versions --- src/DI/TessaExtension.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DI/TessaExtension.php b/src/DI/TessaExtension.php index bec5b3c..b4765b5 100644 --- a/src/DI/TessaExtension.php +++ b/src/DI/TessaExtension.php @@ -56,7 +56,7 @@ public function loadConfiguration() $storage = $builder->addDefinition($this->prefix('storage')) ->setFactory(Storage::class, [$config->outputDir]) ->addSetup('setCheckLastModified', [$config->checkLastModified]) - ->addSetup('setDebugMode', [$config->debugMode]); + ->addSetup('setDebugMode', [$config->debugMode ?? false]); foreach ($config->filters as $filter) { $storage->addSetup('addFilter', [$filter]); @@ -75,10 +75,10 @@ public function loadConfiguration() foreach ($bundles as $name => $params) { $bundle = $builder->addDefinition($this->prefix('bundle.'.$name)) ->setFactory(AssetBundle::class, [$name]) - ->addSetup('setExtendBundle', [$params->extend]) - ->addSetup('setCookieConsent', [$params->cookieConsent]) - ->addSetup('setJoinFiles', [$params->joinFiles]) - ->addSetup('setDeferred', [$params->defer]); + ->addSetup('setExtendBundle', [$params->extend ?? null]) + ->addSetup('setCookieConsent', [$params->cookieConsent ?? null]) + ->addSetup('setJoinFiles', [$params->joinFiles ?? false]) + ->addSetup('setDeferred', [$params->defer ?? false]); foreach ($params->assets as $file) { $bundle->addSetup('discoverAsset', [$file]);