Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '2.0' into 2.1

* 2.0:
  [FrameworkBundle] added support for URIs as an argument to HttpKernel::render()
  [FrameworkBundle] restricted the type of controllers that can be executed by InternalController
  Making it easier to grab the PR template.
  fix double-decoding in the routing system

Conflicts:
	README.md
	src/Symfony/Bundle/FrameworkBundle/EventListener/RouterListener.php
	src/Symfony/Component/Security/Http/HttpUtils.php
  • Loading branch information...
commit 4bee2e9d3a043f2f720d84e8d94f70f91e364c80 2 parents 055daa9 + 532cc9a
Fabien Potencier fabpot authored
4 CONTRIBUTING.md
View
@@ -3,7 +3,9 @@ Contributing
Symfony2 is an open source, community-driven project. If you'd like to contribute,
please read the [Contributing Code][1] part of the documentation. If you're submitting
-a pull request, please follow the guidelines in the [Submitting a Patch][2] section.
+a pull request, please follow the guidelines in the [Submitting a Patch][2] section
+and use the [Pull Request Template][3].
[1]: http://symfony.com/doc/current/contributing/code/index.html
[2]: http://symfony.com/doc/current/contributing/code/patches.html#check-list
+[3]: http://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request
8 README.md
View
@@ -46,17 +46,19 @@ Contributing
Symfony2 is an open source, community-driven project. If you'd like to contribute,
please read the [Contributing Code][4] part of the documentation. If you're submitting
-a pull request, please follow the guidelines in the [Submitting a Patch][5] section.
+a pull request, please follow the guidelines in the [Submitting a Patch][5] section
+and use [Pull Request Template][6].
Running Symfony2 Tests
----------------------
Information on how to run the Symfony2 test suite can be found in the
-[Running Symfony2 Tests][6] section.
+[Running Symfony2 Tests][7] section.
[1]: http://symfony.com/download
[2]: http://symfony.com/get_started
[3]: http://symfony.com/doc/current/
[4]: http://symfony.com/doc/current/contributing/code/index.html
[5]: http://symfony.com/doc/current/contributing/code/patches.html#check-list
-[6]: http://symfony.com/doc/master/contributing/code/tests.html
+[6]: http://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request
+[7]: http://symfony.com/doc/master/contributing/code/tests.html
29 src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php
View
@@ -31,6 +31,35 @@ class InternalController extends ContainerAware
*/
public function indexAction($path, $controller)
{
+ // safeguard
+ if (!is_string($controller)) {
+ throw new \RuntimeException('A Controller must be a string.');
+ }
+
+ // check that the controller looks like a controller
+ if (false === strpos($controller, '::')) {
+ $count = substr_count($controller, ':');
+ if (2 == $count) {
+ // the convention already enforces the Controller suffix
+ } elseif (1 == $count) {
+ // controller in the service:method notation
+ list($service, $method) = explode(':', $controller, 2);
+ $class = get_class($this->container->get($service));
+
+ if (!preg_match('/Controller$/', $class)) {
+ throw new \RuntimeException('A Controller class name must end with Controller.');
+ }
+ } else {
+ throw new \LogicException('Unable to parse the Controller name.');
+ }
+ } else {
+ list($class, $method) = explode('::', $controller, 2);
+
+ if (!preg_match('/Controller$/', $class)) {
+ throw new \RuntimeException('A Controller class name must end with Controller.');
+ }
+ }
+
$request = $this->container->get('request');
$attributes = $request->attributes;
9 src/Symfony/Bundle/FrameworkBundle/HttpKernel.php
View
@@ -139,8 +139,13 @@ public function render($controller, array $options = array())
$request = $this->container->get('request');
- // controller or URI?
- if (0 === strpos($controller, '/')) {
+ // controller or URI or path?
+ if (0 === strpos($controller, 'http://') || 0 === strpos($controller, 'https://')) {
+ $subRequest = Request::create($controller, 'get', array(), $request->cookies->all(), array(), $request->server->all());
+ if ($session = $request->getSession()) {
+ $subRequest->setSession($session);
+ }
+ } elseif (0 === strpos($controller, '/')) {
$subRequest = Request::create($request->getUriForPath($controller), 'get', array(), $request->cookies->all(), array(), $request->server->all());
if ($session = $request->getSession()) {
$subRequest->setSession($session);
52 src/Symfony/Bundle/FrameworkBundle/Tests/Controller/InternalControllerTest.php
View
@@ -0,0 +1,52 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\InternalController;
+use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
+use Symfony\Component\HttpFoundation\Request;
+
+class InternalControllerTest extends TestCase
+{
+ /**
+ * @expectedException \RuntimeException
+ * @expectedExceptionMessage A Controller class name must end with Controller.
+ */
+ public function testWithAClassMethodController()
+ {
+ $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+
+ $controller = new InternalController();
+ $controller->setContainer($container);
+
+ $controller->indexAction('/', 'Symfony\Component\HttpFoundation\Request::getPathInfo');
+ }
+
+ /**
+ * @expectedException \RuntimeException
+ * @expectedExceptionMessage A Controller class name must end with Controller.
+ */
+ public function testWithAServiceController()
+ {
+ $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container
+ ->expects($this->once())
+ ->method('get')
+ ->will($this->returnValue(new Request()))
+ ;
+
+ $controller = new InternalController();
+ $controller->setContainer($container);
+
+ $controller->indexAction('/', 'service:method');
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.