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] Add documentation about doctrine.event_subscriber priority#14970

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

Merged
Merged
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
37 changes: 31 additions & 6 deletionsdoctrine/events.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,7 +166,7 @@ with the ``doctrine.event_listener`` tag:
# this is the only required option for the lifecycle listener tag
event: 'postPersist'

# listeners can define their priority in case multiple listeners are associated
# listeners can define their priority in case multiplesubscribers orlisteners are associated
# to the same event (default priority = 0; higher numbers = listener is run earlier)
priority: 500

Expand All@@ -184,7 +184,7 @@ with the ``doctrine.event_listener`` tag:

<!--
* 'event' is the only required option that defines the lifecycle listener
* 'priority': used when multiple listeners are associated to the same event
* 'priority': used when multiplesubscribers orlisteners are associated to the same event
* (default priority = 0; higher numbers = listener is run earlier)
* 'connection': restricts the listener to a specific Doctrine connection
-->
Expand DownExpand Up@@ -213,7 +213,7 @@ with the ``doctrine.event_listener`` tag:
// this is the only required option for the lifecycle listener tag
'event' => 'postPersist',

// listeners can define their priority in case multiple listeners are associated
// listeners can define their priority in case multiplesubscribers orlisteners are associated
// to the same event (default priority = 0; higher numbers = listener is run earlier)
'priority' => 500,

Expand DownExpand Up@@ -428,7 +428,14 @@ with the ``doctrine.event_subscriber`` tag:

App\EventListener\DatabaseActivitySubscriber:
tags:
- { name: 'doctrine.event_subscriber' }
- name: 'doctrine.event_subscriber'

# subscribers can define their priority in case multiple subscribers or listeners are associated
# to the same event (default priority = 0; higher numbers = listener is run earlier)
priority: 500

# you can also restrict listeners to a specific Doctrine connection
connection: 'default'

.. code-block:: xml

Expand All@@ -439,8 +446,15 @@ with the ``doctrine.event_subscriber`` tag:
<services>
<!-- ... -->

<!--
* 'priority': used when multiple subscribers or listeners are associated to the same event
* (default priority = 0; higher numbers = listener is run earlier)
* 'connection': restricts the listener to a specific Doctrine connection
-->
<service id="App\EventListener\DatabaseActivitySubscriber">
<tag name="doctrine.event_subscriber"/>
<tag name="doctrine.event_subscriber" priority="500" connection="default"/>
</service>

</service>
</services>
</container>
Expand All@@ -456,7 +470,14 @@ with the ``doctrine.event_subscriber`` tag:
$services = $configurator->services();

$services->set(DatabaseActivitySubscriber::class)
->tag('doctrine.event_subscriber')
->tag('doctrine.event_subscriber'[
// subscribers can define their priority in case multiple subscribers or listeners are associated
// to the same event (default priority = 0; higher numbers = listener is run earlier)
'priority' => 500,

# you can also restrict listeners to a specific Doctrine connection
'connection' => 'default',
])
;
};

Expand DownExpand Up@@ -505,6 +526,10 @@ can do it in the service configuration:
;
};

.. versionadded:: 5.3

Handling priority for subscribers alongside listeners has been introduced in Symfony 5.3.

.. tip::

Symfony loads (and instantiates) Doctrine subscribers whenever the
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp