Skip to content
Permalink
Browse files

Allow autowiring translator by Symfony\Contracts\Translation\Translat…

…orInterface
  • Loading branch information
jiripudil authored and aleswita committed Dec 14, 2019
1 parent 79c4f3e commit cad503e616a9da8b7b1d0cb7938f8fbc9aabdde1
Showing with 5 additions and 2 deletions.
  1. +2 −2 src/DI/TranslationExtension.php
  2. +3 −0 tests/Tests/DI/TranslationExtension.phpt
@@ -121,11 +121,11 @@ public function loadConfiguration(): void
}

$translator = $builder->addDefinition($this->prefix('translator'))
->setType(Nette\Localization\ITranslator::class)
->setFactory($factory, ['defaultLocale' => $this->config->locales->default, 'cacheDir' => $this->config->cache->dir, 'debug' => $this->config->debug])
->addSetup('setLocalesWhitelist', [$this->config->locales->whitelist])
->addSetup('setConfigCacheFactory', [$configCacheFactory])
->addSetup('setFallbackLocales', [$this->config->locales->fallback]);
->addSetup('setFallbackLocales', [$this->config->locales->fallback])
->setAutowired([Nette\Localization\ITranslator::class, Symfony\Contracts\Translation\TranslatorInterface::class]);

// Loaders
foreach ($this->config->loaders as $k1 => $v1) {
@@ -97,6 +97,9 @@ class TranslationExtension extends Tests\TestAbstract
$foo = end($foo);
Tester\Assert::same('messages', end($foo));
Tester\Assert::true(Nette\Utils\Strings::contains(key($foo), 'messages.cs_CZ.neon'));

$symfonyTranslator = $container->getByType(Symfony\Contracts\Translation\TranslatorInterface::class);
Tester\Assert::same($translator, $symfonyTranslator);
}

public function test04(): void

0 comments on commit cad503e

Please sign in to comment.
You can’t perform that action at this time.