Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c6a5316

Browse filesBrowse files
author
Amrouche Hamza
committed
[Profiler][Translation] Logging false by default and desactivated when using the profiler
1 parent 3b54b3d commit c6a5316
Copy full SHA for c6a5316

File tree

4 files changed

+60
-3
lines changed
Filter options

4 files changed

+60
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public function process(ContainerBuilder $container)
2828
if (!$container->hasAlias('logger') || !$container->hasAlias('translator')) {
2929
return;
3030
}
31+
if ($container->has('profiler')) {
32+
$container->hasParameter('translator.logging') && $container->setParameter('translator.logging', false);
33+
}
3134

3235
if ($container->hasParameter('translator.logging') && $container->getParameter('translator.logging')) {
3336
$translatorAlias = $container->getAlias('translator');

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode)
644644
->prototype('scalar')->end()
645645
->defaultValue(array('en'))
646646
->end()
647-
->booleanNode('logging')->defaultValue($this->debug)->end()
647+
->booleanNode('logging')->defaultValue(false)->end()
648648
->arrayNode('paths')
649649
->prototype('scalar')->end()
650650
->end()

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php
+55-1Lines changed: 55 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));
@@ -64,6 +64,60 @@ public function testProcess()
6464
$pass->process($container);
6565
}
6666

67+
public function testProcessWithProfiler()
68+
{
69+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
70+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
71+
$parameterBag = $this->getMockBuilder('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface')->getMock();
72+
73+
$container->expects($this->exactly(2))
74+
->method('hasAlias')
75+
->will($this->returnValue(true));
76+
77+
$container->expects($this->once())
78+
->method('getParameter')
79+
->will($this->returnValue(true));
80+
81+
$container->expects($this->once())
82+
->method('getAlias')
83+
->will($this->returnValue('translation.default'));
84+
85+
$container->expects($this->exactly(3))
86+
->method('getDefinition')
87+
->will($this->returnValue($definition));
88+
89+
$container->expects($this->atLeastOnce())
90+
->method('hasParameter')
91+
->with('translator.logging')
92+
->will($this->returnValue(true));
93+
94+
$container->expects($this->atLeastOnce())
95+
->method('setParameter')
96+
->with('translator.logging')
97+
->will($this->returnValue(true));
98+
99+
$container->expects($this->atLeastOnce())
100+
->method('has')
101+
->with('profiler')
102+
->will($this->returnValue(true));
103+
104+
$parameterBag->expects($this->once())
105+
->method('resolveValue')
106+
->will($this->returnValue("Symfony\Bundle\FrameworkBundle\Translation\Translator"));
107+
108+
$container->expects($this->once())
109+
->method('getParameterBag')
110+
->will($this->returnValue($parameterBag));
111+
112+
$container->expects($this->once())
113+
->method('getReflectionClass')
114+
->with('Symfony\Bundle\FrameworkBundle\Translation\Translator')
115+
->will($this->returnValue(new \ReflectionClass('Symfony\Bundle\FrameworkBundle\Translation\Translator')));
116+
117+
$pass = new LoggingTranslatorPass();
118+
$pass->process($container);
119+
}
120+
67121
public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition()
68122
{
69123
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ protected static function getBundleDefaultConfig()
253253
'translator' => array(
254254
'enabled' => !class_exists(FullStack::class),
255255
'fallbacks' => array('en'),
256-
'logging' => true,
256+
'logging' => false,
257257
'paths' => array(),
258258
),
259259
'validation' => array(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.