Skip to content

Commit

Permalink
Merge branch '3.4'
Browse files Browse the repository at this point in the history
* 3.4:
  added foward compatibility for the removal of bundle inheritance in 4.0
  • Loading branch information
fabpot committed Sep 26, 2017
2 parents 4cdfebd + efdba48 commit d47b833
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
Expand Up @@ -73,6 +73,11 @@ public function parse($controller)
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)) {
Expand Down
Expand Up @@ -16,6 +16,7 @@
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
{
Expand Down Expand Up @@ -141,14 +142,21 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag
);

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
Expand Down
Expand Up @@ -120,14 +120,21 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag
);

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
Expand Down
Expand Up @@ -14,6 +14,7 @@
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
{
Expand Down Expand Up @@ -98,10 +99,17 @@ public function testMissingControllers($name)

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;
}

/**
Expand Down
Expand Up @@ -194,7 +194,7 @@ private function getBundleHierarchy(ContainerBuilder $container, array $config)
}
$container->addResource(new FileExistenceResource($dir));

if (null === $bundle['parent']) {
if (!isset($bundle['parent']) || null === $bundle['parent']) {
continue;
}

Expand Down

0 comments on commit d47b833

Please sign in to comment.