Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Doctrine Events#79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
beberlei wants to merge4 commits intosymfony:masterfrombeberlei:DoctrineEvents
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletionsguides/doctrine/mongodb-odm/configuration.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -294,5 +294,13 @@ Later you can retrieve the persisted document by its id::
}
}

Registering Event Listeners and Subscribers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Registering events works like described in the :ref:`ORM Bundle documentation <doctrine-event-config>`.
The MongoDB event tags are called "doctrine.odm.mongodb.default_event_listener" and
"doctrine.odm.mongodb.default_event_subscriber" respectively where "default" is the name of the
MongoDB document manager.

.. _MongoDB: http://www.mongodb.org/
.. _documentation: http://www.doctrine-project.org/projects/mongodb_odm/1.0/docs/en
62 changes: 62 additions & 0 deletionsguides/doctrine/orm/configuration.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,3 +147,65 @@ retrieve it from the Symfony Dependency Injection Container::

The service "doctrine.orm.entity_manager" is an alias for the default entity
manager defined in the "default_entity_manager" configuration option.

.. _doctrine-event-config:

Registering Event Listeners and Subscribers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Doctrine ships with an event system that allows to hook into many different
events happening during the lifecycle of entities or at other occasions.

To register services to act as event listeners or subscribers (listeners from here)
you have to tag them with the appropriate names. Depending on your use-case you can hook
a listener into every DBAL Connection and ORM Entity Manager or just into one
specific DBAL connection and all the EntityManagers that use this connection.

.. configuration-block::

.. code-block:: yaml

doctrine.dbal:
default_connection: default
connections:
default:
driver: pdo_sqlite
memory: true

services:
my.listener:
class: MyEventListener
tags:
- { name: doctrine.common.event_listener }
my.listener2:
class: MyEventListener2
tags:
- { name: doctrine.dbal.default_event_listener }
my.subscriber:
class: MyEventSubscriber
tags:
- { name: doctrine.dbal.default_event_subscriber }

.. code-block:: xml

<?xml version="1.0" ?>
<container xmlns="http://symfony-project.org/2.0/container"
xmlns:doctrine="http://www.symfony-project.org/schema/dic/doctrine">
<doctrine:dbal default-connection="default">
<doctrine:connections>
<doctrine:connection driver="pdo_sqlite" memory="true" />
</doctrine:connections>
</doctrine:dbal>

<services>
<service id="my.listener" class="MyEventListener">
<tag name="doctrine.common.event_listener" />
</service>
<service id="my.listener2" class="MyEventListener2">
<tag name="doctrine.dbal.default_event_listener" />
</service>
<service id="my.subscriber" class="MyEventSubscriber">
<tag name="doctrine.dbal.default_event_subscriber" />
</service>
</services>
</container>
4 changes: 2 additions & 2 deletionsguides/doctrine/orm/form.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ compatible field that handles arrays of values::
'em' => $em,
'className' => 'Product',
));

$field = new ChoiceField('products', array(
'choices' => $productChoices,
'multiple' => true,
Expand DownExpand Up@@ -79,4 +79,4 @@ be chosen from::
));

$form->add($engineerField);
$form->add($reporterField);
$form->add($reporterField);

[8]ページ先頭

©2009-2025 Movatter.jp