Skip to content

Commit 2a140d7

Browse files
committed
bug #12532 [Doctrine] Fix wrong event class for entity listener in example (sadikoff)
This PR was submitted for the master branch but it was merged into the 4.3 branch instead (closes #12532). Discussion ---------- [Doctrine] Fix wrong event class for entity listener in example Using class `PreUpdateEventArgs` in code example causes an exception: >Argument 2 passed to App\EventListener\UserChangedNotifier::postUpdate() must be an instance of Doctrine\ORM\Event\PreUpdateEventArgs, instance of Doctrine\ORM\Event\LifecycleEventArgs given, called in .../vendor/doctrine/orm/lib/Doctrine/ORM/Event/ListenersInvoker.php on line 112 <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- c5be930 Fix Doctrine Entity Listeners event class
2 parents 8d4022f + c5be930 commit 2a140d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doctrine/events.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ define a listener for the ``postUpdate`` Doctrine event::
233233
namespace App\EventListener;
234234

235235
use App\Entity\User;
236-
use Doctrine\ORM\Event\PreUpdateEventArgs;
236+
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
237237

238238
class UserChangedNotifier
239239
{
240240
// the entity listener methods receive two arguments:
241241
// the entity instance and the lifecycle event
242-
public function postUpdate(User $user, PreUpdateEventArgs $event)
242+
public function postUpdate(User $user, LifecycleEventArgs $event)
243243
{
244244
// ... do something to notify the changes
245245
}

0 commit comments

Comments
 (0)