minor #24339 Forward compatibility for the removal of bundle inheritance in 4.0 (fabpot)

This PR was merged into the 3.4 branch.

Discussion
----------

Forward compatibility for the removal of bundle inheritance in 4.0

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Compat layer so that 3.4 and master combinations of framework/twig bundles and http-kernel work together.

Commits
-------

fba7e543d1 added foward compatibility for the removal of bundle inheritance in 4.0
This commit is contained in:
Fabien Potencier 2017-09-26 15:58:28 -07:00
commit efdba489d9
5 changed files with 40 additions and 12 deletions

View File

@ -73,6 +73,11 @@ class ControllerNameParser
throw new \InvalidArgumentException($message, 0, $e);
}
if (!is_array($allBundles)) {
// happens when HttpKernel is version 4+
$allBundles = array($allBundles);
}
foreach ($allBundles as $b) {
$try = $b->getNamespace().'\\Controller\\'.$controller.'Controller';
if (class_exists($try)) {

View File

@ -16,6 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel;
class TranslationDebugCommandTest extends TestCase
{
@ -141,14 +142,21 @@ class TranslationDebugCommandTest extends TestCase
);
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
->expects($this->any())
->method('getBundle')
->will($this->returnValueMap(array(
array('foo', true, $this->getBundle($this->translationDir)),
array('test', true, $this->getBundle('test')),
)));
->will($this->returnValueMap($returnValues));
}
$kernel

View File

@ -120,14 +120,21 @@ class TranslationUpdateCommandTest extends TestCase
);
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
->expects($this->any())
->method('getBundle')
->will($this->returnValueMap(array(
array('foo', true, $this->getBundle($this->translationDir)),
array('test', true, $this->getBundle('test')),
)));
->will($this->returnValueMap($returnValues));
}
$kernel

View File

@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
use Composer\Autoload\ClassLoader;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
use Symfony\Component\HttpKernel\Kernel;
class ControllerNameParserTest extends TestCase
{
@ -98,10 +99,17 @@ class ControllerNameParserTest extends TestCase
public function getMissingControllersTest()
{
return array(
array('FooBundle:Fake:index'), // a normal bundle
array('SensioFooBundle:Fake:index'), // a bundle with children
// a normal bundle
$bundles = array(
array('FooBundle:Fake:index'),
);
// a bundle with children
if (Kernel::VERSION_ID < 40000) {
$bundles[] = array('SensioFooBundle:Fake:index');
}
return $bundles;
}
/**

View File

@ -214,7 +214,7 @@ class TwigExtension extends Extension
}
$container->addResource(new FileExistenceResource($dir));
if (null === $bundle['parent']) {
if (!isset($bundle['parent']) || null === $bundle['parent']) {
continue;
}