Skip to content

Commit d82c309

Browse files
committed
doctrine.rst - suggestions by ryan symfony#1
1 parent a01e17d commit d82c309

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

reference/configuration/doctrine.rst

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,15 @@ Keep in mind that you can't use both syntaxes at the same time.
502502
Custom Mapping
503503
--------------
504504

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.
507508
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
510514

511515
.. configuration-block::
512516

@@ -520,7 +524,7 @@ Keep in mind that the bundle you want to overwrite has to exist.
520524
mappings:
521525
# ...
522526
AppBundle:
523-
dir: Resources/config/doctrine
527+
dir: SomeResources/config/doctrine
524528
525529
.. code-block:: xml
526530
@@ -530,7 +534,7 @@ Keep in mind that the bundle you want to overwrite has to exist.
530534
531535
<doctrine:config>
532536
<doctrine:orm auto-mapping="true">
533-
<mapping name="AppBundle" dir="Resources/config/doctrine" />
537+
<mapping name="AppBundle" dir="SomeResources/config/doctrine" />
534538
</doctrine:orm>
535539
</doctrine:config>
536540
</container>
@@ -541,13 +545,16 @@ Keep in mind that the bundle you want to overwrite has to exist.
541545
'orm' => array(
542546
'auto_mapping' => true,
543547
'mappings' => array(
544-
'AppBundle' => array('dir' => 'Resources/config/doctrine'),
548+
'AppBundle' => array('dir' => 'SomeResources/config/doctrine'),
545549
),
546550
),
547551
));
548552
549553
You can also create new mappings. For example outside of the Symfony folder.
550554

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+
551558
.. configuration-block::
552559

553560
.. code-block:: yaml
@@ -612,9 +619,10 @@ The ``ResourceConfigurationDirectory``, by default, points to
612619
``Resources/config/doctrine``.
613620

614621
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.
616624

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
618626
there is an ``Entity`` folder in the bundle's root directory.
619627
If the folder does not exist, Doctrine will fall back to using an annotation driver.
620628

0 commit comments

Comments
 (0)