Merge branch '2.1'
* 2.1: [FrameworkBundle] added support for URIs as an argument to HttpKernel::render() [FrameworkBundle] restricted the type of controllers that can be executed by InternalController [Process] Allow non-blocking start with PhpProcess Making it easier to grab the PR template. [Locale] fixed a test Fixed failing test fix double-decoding in the routing system Conflicts: src/Symfony/Component/Process/PhpProcess.php
This commit is contained in:
commit
2c9083a6e0
@ -3,7 +3,9 @@ Contributing
|
|||||||
|
|
||||||
Symfony2 is an open source, community-driven project. If you'd like to contribute,
|
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
|
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
|
[1]: http://symfony.com/doc/current/contributing/code/index.html
|
||||||
[2]: http://symfony.com/doc/current/contributing/code/patches.html#check-list
|
[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
|
||||||
|
@ -46,17 +46,19 @@ Contributing
|
|||||||
|
|
||||||
Symfony2 is an open source, community-driven project. If you'd like to contribute,
|
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
|
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
|
Running Symfony2 Tests
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
Information on how to run the Symfony2 test suite can be found in the
|
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
|
[1]: http://symfony.com/download
|
||||||
[2]: http://symfony.com/get_started
|
[2]: http://symfony.com/get_started
|
||||||
[3]: http://symfony.com/doc/current/
|
[3]: http://symfony.com/doc/current/
|
||||||
[4]: http://symfony.com/doc/current/contributing/code/index.html
|
[4]: http://symfony.com/doc/current/contributing/code/index.html
|
||||||
[5]: http://symfony.com/doc/current/contributing/code/patches.html#check-list
|
[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
|
||||||
|
@ -31,6 +31,35 @@ class InternalController extends ContainerAware
|
|||||||
*/
|
*/
|
||||||
public function indexAction($path, $controller)
|
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');
|
$request = $this->container->get('request');
|
||||||
$attributes = $request->attributes;
|
$attributes = $request->attributes;
|
||||||
|
|
||||||
|
@ -151,8 +151,13 @@ class HttpKernel extends BaseHttpKernel
|
|||||||
|
|
||||||
$request = $this->container->get('request');
|
$request = $this->container->get('request');
|
||||||
|
|
||||||
// controller or URI?
|
// controller or URI or path?
|
||||||
if (0 === strpos($controller, '/')) {
|
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());
|
$subRequest = Request::create($request->getUriForPath($controller), 'get', array(), $request->cookies->all(), array(), $request->server->all());
|
||||||
if ($session = $request->getSession()) {
|
if ($session = $request->getSession()) {
|
||||||
$subRequest->setSession($session);
|
$subRequest->setSession($session);
|
||||||
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
@ -66,7 +66,7 @@ class StubLocaleTest extends LocaleTestCase
|
|||||||
|
|
||||||
public function testGetCurrenciesData()
|
public function testGetCurrenciesData()
|
||||||
{
|
{
|
||||||
$symbol = $this->isSameAsIcuVersion('4.8') ? 'BR$' : 'R$';
|
$symbol = $this->isGreaterOrEqualThanIcuVersion('4.8') ? 'BR$' : 'R$';
|
||||||
|
|
||||||
$currencies = StubLocale::getCurrenciesData('en');
|
$currencies = StubLocale::getCurrenciesData('en');
|
||||||
$this->assertEquals($symbol, $currencies['BRL']['symbol']);
|
$this->assertEquals($symbol, $currencies['BRL']['symbol']);
|
||||||
|
@ -57,18 +57,9 @@ class PhpProcess extends Process
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the process.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param Closure|string|array $callback A PHP callback to run whenever there is some
|
|
||||||
* output available on STDOUT or STDERR
|
|
||||||
*
|
|
||||||
* @return integer The exit status code
|
|
||||||
*
|
|
||||||
* @throws Exception\RuntimeException
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
*/
|
||||||
public function run($callback = null)
|
public function start($callback = null)
|
||||||
{
|
{
|
||||||
if (null === $this->getCommandLine()) {
|
if (null === $this->getCommandLine()) {
|
||||||
if (false === $php = $this->executableFinder->find()) {
|
if (false === $php = $this->executableFinder->find()) {
|
||||||
@ -77,6 +68,6 @@ class PhpProcess extends Process
|
|||||||
$this->setCommandLine($php);
|
$this->setCommandLine($php);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::run($callback);
|
return parent::start($callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
src/Symfony/Component/Process/Tests/PhpProcessTest.php
Normal file
21
src/Symfony/Component/Process/Tests/PhpProcessTest.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symfony\Component\Process\Tests;
|
||||||
|
|
||||||
|
use Symfony\Component\Process\PhpProcess;
|
||||||
|
|
||||||
|
class PhpProcessTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testNonBlockingWorks()
|
||||||
|
{
|
||||||
|
$expected = 'hello world!';
|
||||||
|
$process = new PhpProcess(<<<PHP
|
||||||
|
<?php echo '$expected';
|
||||||
|
PHP
|
||||||
|
);
|
||||||
|
$process->start();
|
||||||
|
$process->wait();
|
||||||
|
$this->assertEquals($expected, $process->getOutput());
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user