added foward compatibility for the removal of bundle inheritance in 4.0
This commit is contained in:
parent
701d41cc33
commit
fba7e543d1
@ -73,6 +73,11 @@ class ControllerNameParser
|
|||||||
throw new \InvalidArgumentException($message, 0, $e);
|
throw new \InvalidArgumentException($message, 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_array($allBundles)) {
|
||||||
|
// happens when HttpKernel is version 4+
|
||||||
|
$allBundles = array($allBundles);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($allBundles as $b) {
|
foreach ($allBundles as $b) {
|
||||||
$try = $b->getNamespace().'\\Controller\\'.$controller.'Controller';
|
$try = $b->getNamespace().'\\Controller\\'.$controller.'Controller';
|
||||||
if (class_exists($try)) {
|
if (class_exists($try)) {
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
|
|||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
use Symfony\Component\HttpKernel;
|
||||||
|
|
||||||
class TranslationDebugCommandTest extends TestCase
|
class TranslationDebugCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -141,14 +142,21 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (null === $kernel) {
|
if (null === $kernel) {
|
||||||
|
$returnValues = array(
|
||||||
|
array('foo', $this->getBundle($this->translationDir)),
|
||||||
|
array('test', $this->getBundle('test')),
|
||||||
|
);
|
||||||
|
if (HttpKernel\Kernel::VERSION_ID < 40000) {
|
||||||
|
$returnValues = array(
|
||||||
|
array('foo', true, $this->getBundle($this->translationDir)),
|
||||||
|
array('test', true, $this->getBundle('test')),
|
||||||
|
);
|
||||||
|
}
|
||||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
->will($this->returnValueMap(array(
|
->will($this->returnValueMap($returnValues));
|
||||||
array('foo', true, $this->getBundle($this->translationDir)),
|
|
||||||
array('test', true, $this->getBundle('test')),
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$kernel
|
$kernel
|
||||||
|
@ -120,14 +120,21 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (null === $kernel) {
|
if (null === $kernel) {
|
||||||
|
$returnValues = array(
|
||||||
|
array('foo', $this->getBundle($this->translationDir)),
|
||||||
|
array('test', $this->getBundle('test')),
|
||||||
|
);
|
||||||
|
if (HttpKernel\Kernel::VERSION_ID < 40000) {
|
||||||
|
$returnValues = array(
|
||||||
|
array('foo', true, $this->getBundle($this->translationDir)),
|
||||||
|
array('test', true, $this->getBundle('test')),
|
||||||
|
);
|
||||||
|
}
|
||||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
->will($this->returnValueMap(array(
|
->will($this->returnValueMap($returnValues));
|
||||||
array('foo', true, $this->getBundle($this->translationDir)),
|
|
||||||
array('test', true, $this->getBundle('test')),
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$kernel
|
$kernel
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
|||||||
use Composer\Autoload\ClassLoader;
|
use Composer\Autoload\ClassLoader;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
|
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
|
||||||
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
|
||||||
class ControllerNameParserTest extends TestCase
|
class ControllerNameParserTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -98,10 +99,17 @@ class ControllerNameParserTest extends TestCase
|
|||||||
|
|
||||||
public function getMissingControllersTest()
|
public function getMissingControllersTest()
|
||||||
{
|
{
|
||||||
return array(
|
// a normal bundle
|
||||||
array('FooBundle:Fake:index'), // a normal bundle
|
$bundles = array(
|
||||||
array('SensioFooBundle:Fake:index'), // a bundle with children
|
array('FooBundle:Fake:index'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// a bundle with children
|
||||||
|
if (Kernel::VERSION_ID < 40000) {
|
||||||
|
$bundles[] = array('SensioFooBundle:Fake:index');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $bundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,7 +214,7 @@ class TwigExtension extends Extension
|
|||||||
}
|
}
|
||||||
$container->addResource(new FileExistenceResource($dir));
|
$container->addResource(new FileExistenceResource($dir));
|
||||||
|
|
||||||
if (null === $bundle['parent']) {
|
if (!isset($bundle['parent']) || null === $bundle['parent']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user