Skip to content

Commit

Permalink
Fix Doctrine Entity Listeners event class
Browse files Browse the repository at this point in the history
using class `PreUpdateEventArgs` causes 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
  • Loading branch information
sadikoff authored and weaverryan committed Oct 22, 2019
1 parent 8d4022f commit c5be930
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doctrine/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ define a listener for the ``postUpdate`` Doctrine event::
namespace App\EventListener;

use App\Entity\User;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;

class UserChangedNotifier
{
// the entity listener methods receive two arguments:
// the entity instance and the lifecycle event
public function postUpdate(User $user, PreUpdateEventArgs $event)
public function postUpdate(User $user, LifecycleEventArgs $event)
{
// ... do something to notify the changes
}
Expand Down

0 comments on commit c5be930

Please sign in to comment.