Allow syntax like `{% render "AcmeDemoBundle:Frontend/Default:index" %}`

Bug fix: yes
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2424
This commit is contained in:
docteurklein 2011-10-18 16:22:42 +02:00
parent 347053c363
commit 78883f90a6
3 changed files with 24 additions and 0 deletions

View File

@ -49,6 +49,7 @@ class ControllerNameParser
} }
list($bundle, $controller, $action) = $parts; list($bundle, $controller, $action) = $parts;
$controller = str_replace('/', '\\', $controller);
$class = null; $class = null;
$logs = array(); $logs = array();
foreach ($this->kernel->getBundle($bundle, false) as $b) { foreach ($this->kernel->getBundle($bundle, false) as $b) {

View File

@ -44,6 +44,8 @@ class ControllerNameParserTest extends TestCase
$this->assertEquals('TestBundle\FooBundle\Controller\Sub\DefaultController::indexAction', $parser->parse('FooBundle:Sub\Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\FooBundle\Controller\Sub\DefaultController::indexAction', $parser->parse('FooBundle:Sub\Default:index'), '->parse() converts a short a:b:c notation string to a class::method string');
$this->assertEquals('TestBundle\Fabpot\FooBundle\Controller\DefaultController::indexAction', $parser->parse('SensioFooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\Fabpot\FooBundle\Controller\DefaultController::indexAction', $parser->parse('SensioFooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string');
$this->assertEquals('TestBundle\Sensio\Cms\FooBundle\Controller\DefaultController::indexAction', $parser->parse('SensioCmsFooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\Sensio\Cms\FooBundle\Controller\DefaultController::indexAction', $parser->parse('SensioCmsFooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string');
$this->assertEquals('TestBundle\FooBundle\Controller\Test\DefaultController::indexAction', $parser->parse('FooBundle:Test\\Default:index'), '->parse() converts a short a:b:c notation string to a class::method string');
$this->assertEquals('TestBundle\FooBundle\Controller\Test\DefaultController::indexAction', $parser->parse('FooBundle:Test/Default:index'), '->parse() converts a short a:b:c notation string to a class::method string');
try { try {
$parser->parse('foo:'); $parser->parse('foo:');

View File

@ -0,0 +1,21 @@
<?php
namespace TestBundle\FooBundle\Controller\Test;
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* DefaultController.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class DefaultController
{
}