Skip to content

Commit

Permalink
Merge branch 'master' of github.com:juniwalk/tessa
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk committed Oct 20, 2022
2 parents d1f49ed + 65d65a4 commit 5273fe0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/DI/TessaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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]);
Expand All @@ -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]);
Expand Down

0 comments on commit 5273fe0

Please sign in to comment.