diff --git a/guides/doctrine/mongodb-odm/configuration.rst b/guides/doctrine/mongodb-odm/configuration.rst index 3341b2c24eb..d4eb98dab53 100644 --- a/guides/doctrine/mongodb-odm/configuration.rst +++ b/guides/doctrine/mongodb-odm/configuration.rst @@ -50,9 +50,9 @@ can control. The following configuration options exist for a mapping: - ``prefix`` A common namespace prefix that all documents of this mapping share. This prefix should never conflict with prefixes of other defined mappings otherwise some of your documents cannot be found by Doctrine. This - option defaults to the bundle namespace + `Documents`, for example for an + option defaults to the bundle namespace + ``Document``, for example for an application bundle called "Hello" prefix would be - "Application\Hello\Documents". + ``Application\Hello\Document``. - ``alias`` Doctrine offers a way to alias document namespaces to simpler, shorter names to be used inqueries or for Repository access. - ``is_bundle`` This option is a derived value from ``dir`` and by default is @@ -64,13 +64,13 @@ can control. The following configuration options exist for a mapping: To avoid having to configure lots of information for your mappings you should follow these conventions: -1. Put all your entities in a directory Documents/ inside your bundle. For -example "Application/Hello/Documents/". +1. Put all your entities in a directory ``Document/`` inside your bundle. For + example ``Application/Hello/Document/``. 2. If you are using xml, yml or php mapping put all your configuration files -into the "Resources/config/doctrine/metadata/doctrine/mongodb/" directory -sufficed with dcm.xml, dcm.yml or dcm.php respectively. -3. Annotations is assumed if an "Documents/" but no -"Resources/config/doctrine/metadata/doctrine/mongodb/" directory is found. + into the ``Resources/config/doctrine/metadata/doctrine/mongodb/`` directory + sufficed with dcm.xml, dcm.yml or dcm.php respectively. +3. Annotations is assumed if an ``Document/`` but no + ``Resources/config/doctrine/metadata/doctrine/mongodb/`` directory is found. The following configuration shows a bunch of mapping examples: @@ -92,6 +92,20 @@ The following configuration shows a bunch of mapping examples: prefix: DoctrineExtensions\Documents\ alias: DExt +Registering Event Listeners and Subscribers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Doctrine uses the lightweight ``Doctrine\Common\EventManager`` class to trigger +a number of different events which you can hook into. You can register Event +Listeners or Subscribers by tagging the respective services with +``doctrine.odm.mongodb._event_listener`` or +``doctrine.odm.mongodb._event_subscriber`` using the Dependency Injenction +container. + +You have to use the name of the MongoDB connection to clearly identify which +connection the listeners should be registered with. If you are using multiple +connections you can hook different events into each connection. + Multiple Connections ~~~~~~~~~~~~~~~~~~~~ diff --git a/guides/doctrine/orm/configuration.rst b/guides/doctrine/orm/configuration.rst index 8db9b645810..c04b149db98 100644 --- a/guides/doctrine/orm/configuration.rst +++ b/guides/doctrine/orm/configuration.rst @@ -66,9 +66,9 @@ can control. The following configuration options exist for a mapping: - ``prefix`` A common namespace prefix that all entities of this mapping share. This prefix should never conflict with prefixes of other defined mappings otherwise some of your entities cannot be found by Doctrine. This - option defaults to the bundle namespace + `Entities`, for example for an + option defaults to the bundle namespace + ``Entity``, for example for an application bundle called "Hello" prefix would be - "Application\Hello\Entities". + ``Application\Hello\Entity``. - ``alias`` Doctrine offers a way to alias entity namespaces to simpler, shorter names to be used in DQL queries or for Repository access. - ``is_bundle`` This option is a derived value from ``dir`` and by default is @@ -80,13 +80,13 @@ can control. The following configuration options exist for a mapping: To avoid having to configure lots of information for your mappings you should follow these conventions: -1. Put all your entities in a directory Entities/ inside your bundle. For -example "Application/Hello/Entities/". +1. Put all your entities in a directory ``Entity/`` inside your bundle. For + example ``Application/Hello/Entity/``. 2. If you are using xml, yml or php mapping put all your configuration files -into the "Resources/config/doctrine/metadata/doctrine/orm/" directory sufficed -with dcm.xml, dcm.yml or dcm.php respectively. -3. Annotations is assumed if an "Entities/" but no -"Resources/config/doctrine/metadata/doctrine/orm/" directory is found. + into the "Resources/config/doctrine/metadata/doctrine/orm/" directory sufficed + with dcm.xml, dcm.yml or dcm.php respectively. +3. Annotations is assumed if an ``Entity/`` but no + "Resources/config/doctrine/metadata/doctrine/orm/" directory is found. The following configuration shows a bunch of mapping examples: @@ -96,7 +96,7 @@ The following configuration shows a bunch of mapping examples: mappings: MyBundle1: ~ MyBundle2: yml - MyBundle3: { type: annotation, dir: Entities/ } + MyBundle3: { type: annotation, dir: Entity/ } MyBundle4: { type: xml, dir: Resources/config/doctrine/mapping } MyBundle5: type: yml @@ -104,10 +104,48 @@ The following configuration shows a bunch of mapping examples: alias: BundleAlias doctrine_extensions: type: xml - dir: %kernel.dir%/../src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Entities - prefix: DoctrineExtensions\Entities\ + dir: %kernel.dir%/../src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Entity + prefix: DoctrineExtensions\Entity\ alias: DExt +Registering Event Listeners and Subscribers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Doctrine uses the lightweight ``Doctrine\Common\EventManager`` class to trigger +a number of different events which you can hook into. You can register Event +Listeners or Subscribers by tagging the respective services with +``doctrine.dbal._event_listener`` or +``doctrine.dbal._event_subscriber`` using the Dependency Injenction +container. + +You have to use the name of the DBAL connection to clearly identify which +connection the listeners should be registered with. If you are using multiple +connections you can hook different events into each connection. + +.. code-block:: xml + + + + + + + + + + + + + + + + + +Although the Event Listener and Subscriber tags are prefixed with ``doctrine.dbal`` +these tags also work for the ORM events. Internally Doctrine re-uses the EventManager +that is registered with the connection for the ORM. + Multiple Entity Managers ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/guides/doctrine/orm/form.rst b/guides/doctrine/orm/form.rst index 63b7ae29167..2c424142095 100644 --- a/guides/doctrine/orm/form.rst +++ b/guides/doctrine/orm/form.rst @@ -28,7 +28,7 @@ compatible field that handles arrays of values:: 'em' => $em, 'className' => 'Product', )); - + $field = new ChoiceField('products', array( 'choices' => $productChoices, 'multiple' => true, @@ -79,4 +79,4 @@ be chosen from:: )); $form->add($engineerField); - $form->add($reporterField); + $form->add($reporterField); \ No newline at end of file