Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed locale of sub-requests when explicitely set by the developer (r…
…efs #8821)
  • Loading branch information
fabpot committed Aug 22, 2013
1 parent 1ad64ee commit b3c3159
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Expand Up @@ -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;

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

$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)
Expand All @@ -41,6 +44,11 @@ public function customFormatAction($_format)
{
return new Response($_format);
}

public function customLocaleAction(Request $request)
{
return new Response($request->getLocale());
}
}

class Bar
Expand Down
Expand Up @@ -28,7 +28,7 @@ public function testFragment($insulate)

$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()
Expand Down
Expand Up @@ -55,9 +55,11 @@ public function render($uri, Request $request, array $options = array())
$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);
Expand Down

0 comments on commit b3c3159

Please sign in to comment.