Skip to content

Commit 86ac9c8

Browse files
fix: Doctrine mapping compiler requirement
1 parent 5782e79 commit 86ac9c8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

CmfRoutingBundle.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,27 @@ public function build(ContainerBuilder $container)
5858
}
5959

6060
/**
61-
* Searches a mapping compiler: try cmf CoreBundle first and fallback on DoctrineBundle.
61+
* Searches a mapping compiler (doctrine bridge compiler is missing in symfony < 2.3).
62+
* Use Cmf\CoreBundle in that case.
6263
*/
6364
private function findDoctrineOrmCompiler()
6465
{
65-
if (class_exists('Symfony\Cmf\Bundle\CoreBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) {
66-
return 'Symfony\Cmf\Bundle\CoreBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass';
67-
}
66+
$symfonyVersion = class_exists('Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass');
6867

69-
if (class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) {
68+
if (symfonyVersion && class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) {
7069
return 'Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass';
7170
}
7271

72+
if (class_exists('Symfony\Cmf\Bundle\CoreBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) {
73+
return 'Symfony\Cmf\Bundle\CoreBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass';
74+
}
75+
7376
return false;
7477
}
7578

79+
/**
80+
* Instantiate compiler now because of SymfonyFileLocator namespace issue (see phpcr method comment).
81+
*/
7682
private function buildBaseOrmCompilerPass($doctrineOrmCompiler)
7783
{
7884
$arguments = array(array(realpath(__DIR__ . '/Resources/config/doctrine-base')), '.orm.xml');

0 commit comments

Comments
 (0)