From 67b460a6e10d84d56b00b048d3bb7fff1cd72bbe Mon Sep 17 00:00:00 2001 From: Romaric Drigon Date: Wed, 9 Apr 2014 14:39:24 +0200 Subject: [PATCH] Added option to disable locale listener --- DependencyInjection/Configuration.php | 1 + DependencyInjection/StofDoctrineExtensionsExtension.php | 2 +- Resources/doc/index.rst | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 95e85b5e..a85f79a7 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -30,6 +30,7 @@ public function getConfigTreeBuilder() ->booleanNode('translation_fallback')->defaultFalse()->end() ->booleanNode('persist_default_translation')->defaultFalse()->end() ->booleanNode('skip_translation_on_load')->defaultFalse()->end() + ->booleanNode('use_request_locale')->defaultTrue()->end() ->end() ; diff --git a/DependencyInjection/StofDoctrineExtensionsExtension.php b/DependencyInjection/StofDoctrineExtensionsExtension.php index 28ed2269..4062595a 100644 --- a/DependencyInjection/StofDoctrineExtensionsExtension.php +++ b/DependencyInjection/StofDoctrineExtensionsExtension.php @@ -80,7 +80,7 @@ public function load(array $configs, ContainerBuilder $container) $this->documentManagers[$name] = $listeners; } - if ($useTranslatable) { + if ($useTranslatable && $config['use_request_locale']) { $container->getDefinition('stof_doctrine_extensions.event_listener.locale') ->setPublic(true) ->addTag('kernel.event_subscriber'); diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 87b55e25..9d8d4ec0 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -226,6 +226,9 @@ the asked language. If you don't provide it explicitly, it will default to stof_doctrine_extensions: default_locale: en_US + # If you use Translatable extension, by default the Symfony2 current locale (from the Request) is used to fetch translated query results. + use_request_locale: true + # Only used if you activated the Uploadable extension uploadable: # Default file path: This is one of the three ways you can configure the path for the Uploadable extension