diff --git a/src/Bridges/ApplicationDI/LatteExtension.php b/src/Bridges/ApplicationDI/LatteExtension.php index 2a43a3323..7a1ddb16b 100644 --- a/src/Bridges/ApplicationDI/LatteExtension.php +++ b/src/Bridges/ApplicationDI/LatteExtension.php @@ -80,6 +80,9 @@ public function loadConfiguration() ->addSetup('enablePhpLinter', [$config->phpLinter]); foreach ($config->extensions as $extension) { + if ($extension === Latte\Essential\TranslatorExtension::class) { + $extension = new Statement($extension, [new Nette\DI\Definitions\Reference(Nette\Localization\Translator::class)]); + } $this->addExtension($extension); } } diff --git a/tests/Bridges.DI/LatteExtension.translator.phpt b/tests/Bridges.DI/LatteExtension.translator.phpt new file mode 100644 index 000000000..f555b460e --- /dev/null +++ b/tests/Bridges.DI/LatteExtension.translator.phpt @@ -0,0 +1,46 @@ +load(Tester\FileMock::create(' +latte: + extensions: + - Latte\Essential\TranslatorExtension + +services: + - Translator +', 'neon')); + +$compiler = new DI\Compiler; +$compiler->addExtension('latte', new Nette\Bridges\ApplicationDI\LatteExtension('')); +$code = $compiler->addConfig($config)->compile(); +eval($code); + +$container = new Container; + +$latte = $container->getService('nette.latteFactory')->create(); +$extensions = Assert::with($latte, fn() => $this->extensions); +Assert::equal(new Latte\Essential\TranslatorExtension(new Translator), $extensions[3]);