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:
commit
efdba489d9
@ -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