diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php index d57050e318..54ebb27cb0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\DependencyInjection\ContainerAware; @@ -29,7 +30,9 @@ class FragmentController extends ContainerAware $html2 = $actions->render($actions->controller('TestBundle:Fragment:customformat', array('_format' => 'html'))); - return new Response($html1.'--'.$html2); + $html3 = $actions->render($actions->controller('TestBundle:Fragment:customlocale', array('_locale' => 'es'))); + + return new Response($html1.'--'.$html2.'--'.$html3); } public function inlinedAction($options, $_format) @@ -41,6 +44,11 @@ class FragmentController extends ContainerAware { return new Response($_format); } + + public function customLocaleAction(Request $request) + { + return new Response($request->getLocale()); + } } class Bar diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php index edfb08b532..14a30a684f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php @@ -28,7 +28,7 @@ class FragmentTest extends WebTestCase $client->request('GET', '/fragment_home'); - $this->assertEquals('bar txt--html', $client->getResponse()->getContent()); + $this->assertEquals('bar txt--html--es', $client->getResponse()->getContent()); } public function getConfigs() diff --git a/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php index 679ef6b575..5ceea78f12 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php @@ -55,9 +55,11 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer $attributes = $reference->attributes; $reference->attributes = array(); - // The request format might have been overriden by the user - if (isset($attributes['_format'])) { - $reference->attributes['_format'] = $attributes['_format']; + // The request format and locale might have been overriden by the user + foreach (array('_format', '_locale') as $key) { + if (isset($attributes[$key])) { + $reference->attributes[$key] = $attributes[$key]; + } } $uri = $this->generateFragmentUri($uri, $request);