Skip to content

Commit b3c3159

Browse files
committed
fixed locale of sub-requests when explicitely set by the developer (refs #8821)
1 parent 1ad64ee commit b3c3159

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
1313

14+
use Symfony\Component\HttpFoundation\Request;
1415
use Symfony\Component\HttpFoundation\Response;
1516
use Symfony\Component\DependencyInjection\ContainerAware;
1617

@@ -29,7 +30,9 @@ public function indexAction()
2930

3031
$html2 = $actions->render($actions->controller('TestBundle:Fragment:customformat', array('_format' => 'html')));
3132

32-
return new Response($html1.'--'.$html2);
33+
$html3 = $actions->render($actions->controller('TestBundle:Fragment:customlocale', array('_locale' => 'es')));
34+
35+
return new Response($html1.'--'.$html2.'--'.$html3);
3336
}
3437

3538
public function inlinedAction($options, $_format)
@@ -41,6 +44,11 @@ public function customFormatAction($_format)
4144
{
4245
return new Response($_format);
4346
}
47+
48+
public function customLocaleAction(Request $request)
49+
{
50+
return new Response($request->getLocale());
51+
}
4452
}
4553

4654
class Bar

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testFragment($insulate)
2828

2929
$client->request('GET', '/fragment_home');
3030

31-
$this->assertEquals('bar txt--html', $client->getResponse()->getContent());
31+
$this->assertEquals('bar txt--html--es', $client->getResponse()->getContent());
3232
}
3333

3434
public function getConfigs()

src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ public function render($uri, Request $request, array $options = array())
5555
$attributes = $reference->attributes;
5656
$reference->attributes = array();
5757

58-
// The request format might have been overriden by the user
59-
if (isset($attributes['_format'])) {
60-
$reference->attributes['_format'] = $attributes['_format'];
58+
// The request format and locale might have been overriden by the user
59+
foreach (array('_format', '_locale') as $key) {
60+
if (isset($attributes[$key])) {
61+
$reference->attributes[$key] = $attributes[$key];
62+
}
6163
}
6264

6365
$uri = $this->generateFragmentUri($uri, $request);

0 commit comments

Comments
 (0)