@@ -502,11 +502,15 @@ Keep in mind that you can't use both syntaxes at the same time.
502
502
Custom Mapping
503
503
--------------
504
504
505
- It's possible to not rely on the auto mapping and set all the configuration
506
- on your own.
505
+ Doctrine's ```auto_mapping `` feature loads annotation configuration from the
506
+ ``Entity/ `` directory of each bundle *and * looks for other formats (e.g. YAML, XML)
507
+ in the ``Resources/config/doctrine``directory.
507
508
508
- For example, you can overwrite the configuration directory for a given bundle.
509
- Keep in mind that the bundle you want to overwrite has to exist.
509
+ If you store metadata somewhere else, you can define your own mappings,
510
+ where you tell Doctrine exactly *where* to look, along with some other information.
511
+
512
+ For example, suppose you decide to store your configuration for `AppBundle` entities
513
+ in the ``app/Resources/config/doctrine `` directory instead
510
514
511
515
.. configuration-block ::
512
516
@@ -520,7 +524,7 @@ Keep in mind that the bundle you want to overwrite has to exist.
520
524
mappings :
521
525
# ...
522
526
AppBundle :
523
- dir : Resources /config/doctrine
527
+ dir : SomeResources /config/doctrine
524
528
525
529
.. code-block :: xml
526
530
@@ -530,7 +534,7 @@ Keep in mind that the bundle you want to overwrite has to exist.
530
534
531
535
<doctrine : config >
532
536
<doctrine : orm auto-mapping =" true" >
533
- <mapping name =" AppBundle" dir =" Resources /config/doctrine" />
537
+ <mapping name =" AppBundle" dir =" SomeResources /config/doctrine" />
534
538
</doctrine : orm >
535
539
</doctrine : config >
536
540
</container >
@@ -541,13 +545,16 @@ Keep in mind that the bundle you want to overwrite has to exist.
541
545
'orm' => array(
542
546
'auto_mapping' => true,
543
547
'mappings' => array(
544
- 'AppBundle' => array('dir' => 'Resources /config/doctrine'),
548
+ 'AppBundle' => array('dir' => 'SomeResources /config/doctrine'),
545
549
),
546
550
),
547
551
));
548
552
549
553
You can also create new mappings. For example outside of the Symfony folder.
550
554
555
+ For example, the following looks for entity classes in the ``App\Entity `` namespace in the
556
+ `src/Entity ` directory and gives them an ``App `` alias (so you can say things like `App:Post `):
557
+
551
558
.. configuration-block ::
552
559
553
560
.. code-block :: yaml
@@ -612,9 +619,10 @@ The ``ResourceConfigurationDirectory``, by default, points to
612
619
``Resources/config/doctrine ``.
613
620
614
621
The bundle looks for (in this order) XML, YAML and PHP files.
615
- Every bundle can by default just register one ``MetadataDriver ``.
622
+ Using the ``automapping `` feature, every bundle can have only one configuration format.
623
+ The bundle will stop as soon as it locates one.
616
624
617
- If it wasn't possible to determine a `` MetadataDriver `` , it will check if
625
+ If it wasn't possible to determine a configuration format , it will check if
618
626
there is an ``Entity `` folder in the bundle's root directory.
619
627
If the folder does not exist, Doctrine will fall back to using an annotation driver.
620
628
0 commit comments