[HttpKernel] renamed path to _path to avoid collision

This commit is contained in:
Fabien Potencier 2013-01-23 07:53:21 +01:00
parent 3193a90815
commit e5135f67be
6 changed files with 15 additions and 15 deletions

View File

@ -61,10 +61,10 @@ class RouterProxyListener implements EventSubscriberInterface
$this->validateRequest($request);
parse_str($request->query->get('path', ''), $attributes);
parse_str($request->query->get('_path', ''), $attributes);
$request->attributes->add($attributes);
$request->attributes->set('_route_params', array_replace($request->attributes->get('_route_params', array()), $attributes));
$request->query->remove('path');
$request->query->remove('_path');
}
protected function validateRequest(Request $request)

View File

@ -52,7 +52,7 @@ abstract class ProxyAwareRenderingStrategy implements RenderingStrategyInterface
$reference->attributes['_controller'] = $reference->controller;
$reference->query['path'] = http_build_query($reference->attributes, '', '&');
$reference->query['_path'] = http_build_query($reference->attributes, '', '&');
return $request->getUriForPath($this->proxyPath.'?'.http_build_query($reference->query, '', '&'));
}

View File

@ -28,7 +28,7 @@ class RouterProxyListenerTest extends \PHPUnit_Framework_TestCase
public function testOnlyTriggeredOnProxyRoute()
{
$request = Request::create('http://example.com/foo?path=foo%3Dbar%26_controller%3Dfoo');
$request = Request::create('http://example.com/foo?_path=foo%3Dbar%26_controller%3Dfoo');
$listener = new RouterProxyListener(new UriSigner('foo'));
$event = $this->createGetResponseEvent($request);
@ -38,7 +38,7 @@ class RouterProxyListenerTest extends \PHPUnit_Framework_TestCase
$listener->onKernelRequest($event);
$this->assertEquals($expected, $request->attributes->all());
$this->assertTrue($request->query->has('path'));
$this->assertTrue($request->query->has('_path'));
}
/**
@ -83,7 +83,7 @@ class RouterProxyListenerTest extends \PHPUnit_Framework_TestCase
public function testWithSignature()
{
$signer = new UriSigner('foo');
$request = Request::create($signer->sign('http://example.com/_proxy?path=foo%3Dbar%26_controller%3Dfoo'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1'));
$request = Request::create($signer->sign('http://example.com/_proxy?_path=foo%3Dbar%26_controller%3Dfoo'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1'));
$listener = new RouterProxyListener($signer);
$event = $this->createGetResponseEvent($request);
@ -91,7 +91,7 @@ class RouterProxyListenerTest extends \PHPUnit_Framework_TestCase
$listener->onKernelRequest($event);
$this->assertEquals(array('foo' => 'bar', '_controller' => 'foo'), $request->attributes->get('_route_params'));
$this->assertFalse($request->query->has('path'));
$this->assertFalse($request->query->has('_path'));
}
private function createGetResponseEvent(Request $request)

View File

@ -47,7 +47,7 @@ class EsiRenderingStrategyTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('<esi:include src="/" />', $strategy->render('/', $request)->getContent());
$this->assertEquals("<esi:comment text=\"This is a comment\" />\n<esi:include src=\"/\" />", $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent());
$this->assertEquals('<esi:include src="/" alt="foo" />', $strategy->render('/', $request, array('alt' => 'foo'))->getContent());
$this->assertEquals('<esi:include src="http://localhost/_proxy?path=_format%3Dhtml%26_controller%3Dmain_controller" alt="http://localhost/_proxy?path=_format%3Dhtml%26_controller%3Dalt_controller" />', $strategy->render(new ControllerReference('main_controller', array(), array()), $request, array('alt' => new ControllerReference('alt_controller', array(), array())))->getContent());
$this->assertEquals('<esi:include src="http://localhost/_proxy?_path=_format%3Dhtml%26_controller%3Dmain_controller" alt="http://localhost/_proxy?_path=_format%3Dhtml%26_controller%3Dalt_controller" />', $strategy->render(new ControllerReference('main_controller', array(), array()), $request, array('alt' => new ControllerReference('alt_controller', array(), array())))->getContent());
}
private function getDefaultStrategy($called = false)

View File

@ -38,7 +38,7 @@ class HIncludeRenderingStrategyTest extends \PHPUnit_Framework_TestCase
{
$strategy = new HIncludeRenderingStrategy(null, new UriSigner('foo'));
$this->assertEquals('<hx:include src="http://localhost/_proxy?path=_format%3Dhtml%26_controller%3Dmain_controller&_hash=hMh5ZalYRj5kWGIGawbIS93KFBE%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
$this->assertEquals('<hx:include src="http://localhost/_proxy?_path=_format%3Dhtml%26_controller%3Dmain_controller&_hash=ctQ5X4vzZnFmmPiqIqnBkVr%2B%2B10%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
}
public function testRenderWithUri()

View File

@ -28,11 +28,11 @@ class ProxyAwareRenderingStrategyTest extends \PHPUnit_Framework_TestCase
public function getGenerateProxyUriData()
{
return array(
array('http://localhost/_proxy?path=_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array(), array())),
array('http://localhost/_proxy?path=_format%3Dxml%26_controller%3Dcontroller', new ControllerReference('controller', array('_format' => 'xml'), array())),
array('http://localhost/_proxy?path=foo%3Dfoo%26_format%3Djson%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo', '_format' => 'json'), array())),
array('http://localhost/_proxy?bar=bar&path=foo%3Dfoo%26_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo'), array('bar' => 'bar'))),
array('http://localhost/_proxy?foo=foo&path=_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array(), array('foo' => 'foo'))),
array('http://localhost/_proxy?_path=_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array(), array())),
array('http://localhost/_proxy?_path=_format%3Dxml%26_controller%3Dcontroller', new ControllerReference('controller', array('_format' => 'xml'), array())),
array('http://localhost/_proxy?_path=foo%3Dfoo%26_format%3Djson%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo', '_format' => 'json'), array())),
array('http://localhost/_proxy?bar=bar&_path=foo%3Dfoo%26_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo'), array('bar' => 'bar'))),
array('http://localhost/_proxy?foo=foo&_path=_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array(), array('foo' => 'foo'))),
);
}
@ -42,7 +42,7 @@ class ProxyAwareRenderingStrategyTest extends \PHPUnit_Framework_TestCase
$request->attributes->set('_format', 'json');
$controller = new ControllerReference('controller', array(), array());
$this->assertEquals('http://localhost/_proxy?path=_format%3Djson%26_controller%3Dcontroller', $this->getStrategy()->doGenerateProxyUri($controller, $request));
$this->assertEquals('http://localhost/_proxy?_path=_format%3Djson%26_controller%3Dcontroller', $this->getStrategy()->doGenerateProxyUri($controller, $request));
}
private function getStrategy()