Skip to content

Commit e219cd0

Browse files
committed
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
2 parents 9b580fc + 40582c4 commit e219cd0

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

Controller/ControllerNameParser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ public function parse($controller)
7373
throw new \InvalidArgumentException($message, 0, $e);
7474
}
7575

76+
if (!is_array($allBundles)) {
77+
// happens when HttpKernel is version 4+
78+
$allBundles = array($allBundles);
79+
}
80+
7681
foreach ($allBundles as $b) {
7782
$try = $b->getNamespace().'\\Controller\\'.$controller.'Controller';
7883
if (class_exists($try)) {

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Tester\CommandTester;
1717
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
1818
use Symfony\Component\Filesystem\Filesystem;
19+
use Symfony\Component\HttpKernel;
1920

2021
class TranslationDebugCommandTest extends TestCase
2122
{
@@ -141,14 +142,21 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag
141142
);
142143

143144
if (null === $kernel) {
145+
$returnValues = array(
146+
array('foo', $this->getBundle($this->translationDir)),
147+
array('test', $this->getBundle('test')),
148+
);
149+
if (HttpKernel\Kernel::VERSION_ID < 40000) {
150+
$returnValues = array(
151+
array('foo', true, $this->getBundle($this->translationDir)),
152+
array('test', true, $this->getBundle('test')),
153+
);
154+
}
144155
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
145156
$kernel
146157
->expects($this->any())
147158
->method('getBundle')
148-
->will($this->returnValueMap(array(
149-
array('foo', true, $this->getBundle($this->translationDir)),
150-
array('test', true, $this->getBundle('test')),
151-
)));
159+
->will($this->returnValueMap($returnValues));
152160
}
153161

154162
$kernel

Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,21 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag
120120
);
121121

122122
if (null === $kernel) {
123+
$returnValues = array(
124+
array('foo', $this->getBundle($this->translationDir)),
125+
array('test', $this->getBundle('test')),
126+
);
127+
if (HttpKernel\Kernel::VERSION_ID < 40000) {
128+
$returnValues = array(
129+
array('foo', true, $this->getBundle($this->translationDir)),
130+
array('test', true, $this->getBundle('test')),
131+
);
132+
}
123133
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
124134
$kernel
125135
->expects($this->any())
126136
->method('getBundle')
127-
->will($this->returnValueMap(array(
128-
array('foo', true, $this->getBundle($this->translationDir)),
129-
array('test', true, $this->getBundle('test')),
130-
)));
137+
->will($this->returnValueMap($returnValues));
131138
}
132139

133140
$kernel

Tests/Controller/ControllerNameParserTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Composer\Autoload\ClassLoader;
1515
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1616
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
17+
use Symfony\Component\HttpKernel\Kernel;
1718

1819
class ControllerNameParserTest extends TestCase
1920
{
@@ -98,10 +99,17 @@ public function testMissingControllers($name)
9899

99100
public function getMissingControllersTest()
100101
{
101-
return array(
102-
array('FooBundle:Fake:index'), // a normal bundle
103-
array('SensioFooBundle:Fake:index'), // a bundle with children
102+
// a normal bundle
103+
$bundles = array(
104+
array('FooBundle:Fake:index'),
104105
);
106+
107+
// a bundle with children
108+
if (Kernel::VERSION_ID < 40000) {
109+
$bundles[] = array('SensioFooBundle:Fake:index');
110+
}
111+
112+
return $bundles;
105113
}
106114

107115
/**

0 commit comments

Comments
 (0)