Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the bundle configutation compatible with using ENV variables #365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading