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:
8181 - ' #. The most important config file is ``app/config/services.yml``, which now is'
8282 - ' The bin/console Command'
8383 - ' .. _`LDAP injection`: http://projects.webappsec.org/w/page/13246947/LDAP%20Injection'
84+ - ' .. versionadded:: 2.7.2' # Doctrine
8485 - ' .. versionadded:: 1.9.0' # Encore
8586 - ' .. versionadded:: 1.11' # Messenger (Middleware / DoctrineBundle)
8687 - ' .. 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
164164
165165.. configuration-block ::
166166
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+
167184 .. code-block :: yaml
168185
169186 # config/services.yaml
@@ -234,6 +251,11 @@ listener in the Symfony application by creating a new service for it and
234251 ;
235252 };
236253
254+ .. versionadded :: 2.7.2
255+
256+ The :class: `Doctrine\\ Bundle\\ DoctrineBundle\\ Attribute\\ AsDoctrineListener `
257+ attribute was introduced in DoctrineBundle 2.7.2.
258+
237259.. tip ::
238260
239261 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
191191 }
192192 }
193193
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+
194227.. _events-subscriber :
195228
196229Creating an Event Subscriber
Original file line number Diff line number Diff line change @@ -464,13 +464,14 @@ storing the newly created password hash::
464464 namespace App\Repository;
465465
466466 // ...
467+ use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
467468 use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
468469
469470 class UserRepository extends EntityRepository implements PasswordUpgraderInterface
470471 {
471472 // ...
472473
473- public function upgradePassword(UserInterface $user, string $newHashedPassword): void
474+ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
474475 {
475476 // set the new hashed password on the User object
476477 $user->setPassword($newHashedPassword);
You can’t perform that action at this time.
0 commit comments