Doctrine Listener Dependency Injection

Dear Laminas Community,

I’m currently facing the problem that I need to inject services into Doctrine Listeners, I’ve spent the whole day looking/trying for a solution but this seems a rare topic in combination with Laminas.

I’m e.g. trying to Inject a CustomService into a UserListener which should do $stuff during postPersist() Event. I’ve tried working with factories for example but it seems that Doctrine Listeners and the Events work out of the Laminas context.

Is there a clean way to inject services into Doctrine Listeners?

Thanks for your help!

How do you create your EntityManager? Do you have any code to see what you’ve tried/already achieved?

I’ve found this for ZF2 but is not suitable for Laminas:

I’ve tried to adopt this for Laminas but without luck. Anybody out there that knows how to “use Laminas Services within Doctrine Listener”