I am stuck with a problem please help me with it. Here is the scenarario:
I have an entity \"User\" and corresponding repository \"UserRepository\", inside my entit
You can use the postLoad event from doctrine and inject everything you want into the entity. The event listener looks like:
getEntity();
if(!($document instanceof MyEntity)){
return;
}
$document->setEntityManager($eventArgs->getEntityManager());
}
}
and service.yml:
services:
app.myentity.listener:
class: AppBundle\EventListener\MyEntityListener
tags:
- { name: doctrine.event_listener, event: postLoad }
Of cource your Entity needs the method setEntityManager and your're ready.