@@ -16,21 +16,32 @@ register the mappings for your model classes.
16
16
of the ODMs. For reusable bundles, rather than duplicate model classes
17
17
just to get the auto mapping, use the compiler pass.
18
18
19
+ .. versionadded :: 2.3
20
+ The mapping compiler pass was added in Symfony 2.3 and DoctrineBundle 1.2.1.
21
+
19
22
20
23
In your bundle class, write the following code to register the compiler pass::
21
24
25
+ use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
26
+
22
27
class FOSUserBundle extends Bundle
23
28
{
24
29
public function build(ContainerBuilder $container)
25
30
{
26
31
parent::build($container);
27
32
$container->addCompilerPass(new ValidationPass());
28
33
29
- if (class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) {
34
+ $compilerClass = 'Doctrine\Bundle\DoctrineBundle\DependencyInjection'
35
+ . '\Compiler\DoctrineOrmMappingsPass';
36
+ if (class_exists($compilerClass)) {
37
+ $modelDir = realpath(__DIR__.'/Resources/config/doctrine/model');
30
38
$mappings = array(
31
- realpath(__DIR__.'/Resources/config/doctrine/model') => 'FOS\UserBundle\Model',
39
+ $modelDir => 'FOS\UserBundle\Model',
32
40
);
33
- $container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, 'fos_user.backend_type_orm'));
41
+ $container->addCompilerPass(
42
+ DoctrineOrmMappingsPass::createXmlMappingDriver(
43
+ $mappings, 'fos_user.backend_type_orm'
44
+ ));
34
45
}
35
46
36
47
// TODO: couch, mongo
0 commit comments