Hi,

 

I am using Doctrine 2 in a Zend Framework 2 application. Is there any way
using ZF2 to inject dependencies into entities returned by Doctrine?
Entities are constructed by Doctrine when retrieved from the database. So
far as I know to inject dependencies in ZF2 I need to instantiate entities
using Service Locator. I cannot see how I can integrate that with Doctrine.
One Option might me Doctrine´s postLoad event. But I cannot see how I could
connect this with the Service Locator. I know how to make my entities
Service Locator aware. But this does not work when the entities are returned
by Doctrine. The only feasible solution I can see right now is to write a
small service which takes the result returned from Doctrine and injects the
required dependencies. Is there a more elegant solution using Service
Locator directly, e.g. Service Locator aware entities?

 

Best Regards

Christian

Reply via email to