Reputation: 1620
I have a doctrine Entity which is already persisted. There is a plugin that listens to livecycle events.
I'd like to trigger these Events without changing the entity at all. Is this possible somehow? I'm searching for something like that:
$entityManager->touch($entity)
Upvotes: 0
Views: 392
Reputation: 1620
I found the solution. You can get the EventManager directly from your EntityManager and call it.
$repo = $this->entityManager->getRepository(MyClass::class);
$entity = $repo->find($parent);
$eventArgs = new LifecycleEventArgs($entity, $this->entityManager);
$this->entityManager
->getEventManager()
->dispatchEvent(\Doctrine\ORM\Events::postPersist, $eventArgs);
Upvotes: 1