diff --git a/src/DI/TessaExtension.php b/src/DI/TessaExtension.php index d103ac3..e793c7f 100644 --- a/src/DI/TessaExtension.php +++ b/src/DI/TessaExtension.php @@ -14,6 +14,7 @@ use Nette\DI\CompilerExtension; use Nette\Schema\Expect; use Nette\Schema\Schema; +use Nette\Utils\ArrayHash; final class TessaExtension extends CompilerExtension { @@ -47,10 +48,14 @@ 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]) - ->addSetup('setDebugMode', [$config->debugMode]); + ->addSetup('setDebugMode', [$config->debugMode ?? false]); foreach ($config->filters as $filter) { $storage->addSetup('addFilter', [$filter]); @@ -69,10 +74,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]);