@@ -40,10 +40,12 @@ public function build(ContainerBuilder $container)
40
40
);
41
41
}
42
42
43
- if (class_exists ('Symfony\Cmf\Bundle\CoreBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass ' )) {
44
- $ container ->addCompilerPass ($ this ->buildBaseOrmCompilerPass ());
43
+ $ doctrineOrmCompiler = $ this ->findDoctrineOrmCompiler ();
44
+
45
+ if ($ doctrineOrmCompiler ) {
46
+ $ container ->addCompilerPass ($ this ->buildBaseOrmCompilerPass ($ doctrineOrmCompiler ));
45
47
$ container ->addCompilerPass (
46
- DoctrineOrmMappingsPass ::createXmlMappingDriver (
48
+ $ doctrineOrmCompiler ::createXmlMappingDriver (
47
49
array (
48
50
realpath (__DIR__ . '/Resources/config/doctrine-model ' ) => 'Symfony\Cmf\Bundle\RoutingBundle\Model ' ,
49
51
realpath (__DIR__ . '/Resources/config/doctrine-orm ' ) => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm ' ,
@@ -55,13 +57,29 @@ public function build(ContainerBuilder $container)
55
57
}
56
58
}
57
59
58
- private function buildBaseOrmCompilerPass ()
60
+ /**
61
+ * Searches a mapping compiler: try cmf CoreBundle first and fallback on DoctrineBundle.
62
+ */
63
+ private function findDoctrineOrmCompiler ()
64
+ {
65
+ if (class_exists ('Symfony\Cmf\Bundle\CoreBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass ' )) {
66
+ return 'Symfony\Cmf\Bundle\CoreBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass ' ;
67
+ }
68
+
69
+ if (class_exists ('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass ' )) {
70
+ return 'Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass ' ;
71
+ }
72
+
73
+ return false ;
74
+ }
75
+
76
+ private function buildBaseOrmCompilerPass ($ doctrineOrmCompiler )
59
77
{
60
78
$ arguments = array (array (realpath (__DIR__ . '/Resources/config/doctrine-base ' )), '.orm.xml ' );
61
79
$ locator = new Definition ('Doctrine\Common\Persistence\Mapping\Driver\DefaultFileLocator ' , $ arguments );
62
80
$ driver = new Definition ('Doctrine\ORM\Mapping\Driver\XmlDriver ' , array ($ locator ));
63
81
64
- return new DoctrineOrmMappingsPass (
82
+ return new $ doctrineOrmCompiler (
65
83
$ driver ,
66
84
array ('Symfony\Component\Routing ' ),
67
85
array ('cmf_routing.dynamic.persistence.orm.manager_name ' ),
0 commit comments