Skip to content

Commit 2b235f9

Browse files
committed
cs cleanup
1 parent c28c3ae commit 2b235f9

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

cookbook/bundles/best_practices.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ The following classes and files have specific emplacements:
137137
.. note::
138138

139139
When building a reusable bundle, model classes should be placed in the
140-
``Model`` namespace. See doc:`../doctrine/mapping_model_classes` for
140+
``Model`` namespace. See :doc:`/cookbook/doctrine/mapping_model_classes` for
141141
how to handle the mapping with a compiler pass.
142142

143143
Classes

cookbook/doctrine/mapping_model_classes.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,32 @@ register the mappings for your model classes.
1616
of the ODMs. For reusable bundles, rather than duplicate model classes
1717
just to get the auto mapping, use the compiler pass.
1818

19+
.. versionadded:: 2.3
20+
The mapping compiler pass was added in Symfony 2.3 and DoctrineBundle 1.2.1.
21+
1922

2023
In your bundle class, write the following code to register the compiler pass::
2124

25+
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
26+
2227
class FOSUserBundle extends Bundle
2328
{
2429
public function build(ContainerBuilder $container)
2530
{
2631
parent::build($container);
2732
$container->addCompilerPass(new ValidationPass());
2833

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');
3038
$mappings = array(
31-
realpath(__DIR__.'/Resources/config/doctrine/model') => 'FOS\UserBundle\Model',
39+
$modelDir => 'FOS\UserBundle\Model',
3240
);
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+
));
3445
}
3546

3647
// TODO: couch, mongo

0 commit comments

Comments
 (0)