Skip to content

Commit

Permalink
#364 Make the bundle configutation compatible with using ENV variable…
Browse files Browse the repository at this point in the history
…s, fix test incompatibility with Symfony 7.x
  • Loading branch information
kick-the-bucket committed Jul 26, 2024
1 parent 03ca2d1 commit 2af890b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
5 changes: 0 additions & 5 deletions DependencyInjection/BazingaJsTranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public function load(array $configs, ContainerBuilder $container): void
->replaceArgument(6, $config['default_domain'])
->replaceArgument(7, $config['http_cache_time']);

// Add fallback locale to active locales if missing
if ($config['active_locales'] && !in_array($config['locale_fallback'], $config['active_locales'])) {
array_push($config['active_locales'], $config['locale_fallback']);
}

$container
->getDefinition('bazinga.jstranslation.translation_dumper')
->replaceArgument(3, $config['locale_fallback'])
Expand Down
4 changes: 4 additions & 0 deletions Dumper/TranslationDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public function __construct(
$this->filesystem = $filesystem;
$this->localeFallback = $localeFallback;
$this->defaultDomain = $defaultDomain;
// Add fallback locale to active locales if missing
if ($activeLocales && !in_array($localeFallback, $activeLocales)) {
array_push($activeLocales, $localeFallback);
}
$this->activeLocales = $activeLocales;
$this->activeDomains = $activeDomains;
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/app/config/base_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ twig:
bazinga_js_translation:
active_locales:
- fr
- en
locale_fallback: en
active_domains:
- messages
- numerics
Expand Down
4 changes: 2 additions & 2 deletions Tests/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bazinga\Bundle\JsTranslationBundle\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\KernelInterface;
Expand All @@ -21,7 +21,7 @@ protected function deleteTmpDir()
$fs->remove($dir);
}

protected static function getContainer(): ContainerInterface
protected static function getContainer(): Container
{
if (!static::$kernel) {
static::$kernel = static::createKernel();
Expand Down

0 comments on commit 2af890b

Please sign in to comment.