Skip to content

Commit 1dd741e

Browse files
author
Amrouche Hamza
committed
[Profiler][Translation] Logging false by default and desactivated when using the profiler
1 parent a522e04 commit 1dd741e

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public function process(ContainerBuilder $container)
2828
return;
2929
}
3030

31+
if ($container->has('profiler') && $container->hasParameter('translator.logging')) {
32+
$container->setParameter('translator.logging', false);
33+
}
34+
3135
if ($container->hasParameter('translator.logging') && $container->getParameter('translator.logging')) {
3236
$translatorAlias = $container->getAlias('translator');
3337
$definition = $container->getDefinition((string) $translatorAlias);

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode)
622622
->prototype('scalar')->end()
623623
->defaultValue(array('en'))
624624
->end()
625-
->booleanNode('logging')->defaultValue($this->debug)->end()
625+
->booleanNode('logging')->defaultValue(false)->end()
626626
->scalarNode('formatter')->defaultValue('translator.formatter.default')->end()
627627
->arrayNode('paths')
628628
->prototype('scalar')->end()

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testProcess()
3838
->method('getDefinition')
3939
->will($this->returnValue($definition));
4040

41-
$container->expects($this->once())
41+
$container->expects($this->atLeastOnce())
4242
->method('hasParameter')
4343
->with('translator.logging')
4444
->will($this->returnValue(true));
@@ -80,6 +80,37 @@ public function testProcess()
8080
$pass->process($container);
8181
}
8282

83+
public function testProcessWithProfiler()
84+
{
85+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
86+
87+
$container->expects($this->exactly(2))
88+
->method('hasAlias')
89+
->will($this->returnValue(true));
90+
91+
$container->expects($this->once())
92+
->method('getParameter')
93+
->will($this->returnValue(false));
94+
95+
$container->expects($this->atLeastOnce())
96+
->method('hasParameter')
97+
->with('translator.logging')
98+
->will($this->returnValue(true));
99+
100+
$container->expects($this->atLeastOnce())
101+
->method('setParameter')
102+
->with('translator.logging')
103+
->will($this->returnValue(false));
104+
105+
$container->expects($this->atLeastOnce())
106+
->method('has')
107+
->with('profiler')
108+
->will($this->returnValue(true));
109+
110+
$pass = new LoggingTranslatorPass();
111+
$pass->process($container);
112+
}
113+
83114
public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition()
84115
{
85116
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected static function getBundleDefaultConfig()
152152
'translator' => array(
153153
'enabled' => !class_exists(FullStack::class),
154154
'fallbacks' => array('en'),
155-
'logging' => true,
155+
'logging' => false,
156156
'formatter' => 'translator.formatter.default',
157157
'paths' => array(),
158158
),

0 commit comments

Comments
 (0)