File tree Expand file tree Collapse file tree 4 files changed +58
-1
lines changed Expand file tree Collapse file tree 4 files changed +58
-1
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ whitelist:
81
81
- ' #. The most important config file is ``app/config/services.yml``, which now is'
82
82
- ' The bin/console Command'
83
83
- ' .. _`LDAP injection`: http://projects.webappsec.org/w/page/13246947/LDAP%20Injection'
84
+ - ' .. versionadded:: 2.7.2' # Doctrine
84
85
- ' .. versionadded:: 1.9.0' # Encore
85
86
- ' .. versionadded:: 1.11' # Messenger (Middleware / DoctrineBundle)
86
87
- ' .. versionadded:: 1.18' # Flex in setup/upgrade_minor.rst
Original file line number Diff line number Diff line change @@ -164,6 +164,23 @@ listener in the Symfony application by creating a new service for it and
164
164
165
165
.. configuration-block ::
166
166
167
+ .. code-block :: attribute
168
+
169
+ // src/App/EventListener/SearchIndexer.php
170
+ namespace App\EventListener;
171
+
172
+ use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
173
+ use Doctrine\ORM\Event\LifecycleEventArgs;
174
+
175
+ #[AsDoctrineListener('postPersist'/*, 500, 'default'*/)]
176
+ class SearchIndexer
177
+ {
178
+ public function postPersist(LifecycleEventArgs $event): void
179
+ {
180
+ // ...
181
+ }
182
+ }
183
+
167
184
.. code-block :: yaml
168
185
169
186
# config/services.yaml
@@ -234,6 +251,11 @@ listener in the Symfony application by creating a new service for it and
234
251
;
235
252
};
236
253
254
+ .. versionadded :: 2.7.2
255
+
256
+ The :class: `Doctrine\\ Bundle\\ DoctrineBundle\\ Attribute\\ AsDoctrineListener `
257
+ attribute was introduced in DoctrineBundle 2.7.2.
258
+
237
259
.. tip ::
238
260
239
261
Symfony loads (and instantiates) Doctrine listeners only when the related
Original file line number Diff line number Diff line change @@ -191,6 +191,39 @@ You can add multiple ``#[AsEventListener()]`` attributes to configure different
191
191
}
192
192
}
193
193
194
+ :class: `Symfony\\ Component\\ EventDispatcher\\ Attribute\\ AsEventListener `
195
+ can also be applied to methods directly::
196
+
197
+ namespace App\EventListener;
198
+
199
+ use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
200
+
201
+ final class MyMultiListener
202
+ {
203
+ #[AsEventListener()]
204
+ public function onCustomEvent(CustomEvent $event): void
205
+ {
206
+ // ...
207
+ }
208
+
209
+ #[AsEventListener(event: 'foo', priority: 42)]
210
+ public function onFoo(): void
211
+ {
212
+ // ...
213
+ }
214
+
215
+ #[AsEventListener(event: 'bar')]
216
+ public function onBarEvent(): void
217
+ {
218
+ // ...
219
+ }
220
+ }
221
+
222
+ .. note ::
223
+
224
+ Note that the attribute doesn't require its ``event `` parameter to be set
225
+ if the method already type-hints the expected event.
226
+
194
227
.. _events-subscriber :
195
228
196
229
Creating an Event Subscriber
Original file line number Diff line number Diff line change @@ -464,13 +464,14 @@ storing the newly created password hash::
464
464
namespace App\Repository;
465
465
466
466
// ...
467
+ use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
467
468
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
468
469
469
470
class UserRepository extends EntityRepository implements PasswordUpgraderInterface
470
471
{
471
472
// ...
472
473
473
- public function upgradePassword(UserInterface $user, string $newHashedPassword): void
474
+ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
474
475
{
475
476
// set the new hashed password on the User object
476
477
$user->setPassword($newHashedPassword);
You can’t perform that action at this time.
0 commit comments