Injecting dependencies into DoctrineResource
Closed this issue · 2 comments
Hello. I would like to inject service to one of DoctrineResource
instances. The use case is that after fetching entity from database I need to call a function drom other service. I tried to register my own abstract factory, but the DoctrineResourceFactory
is called 1st. Sadly since zend-servicemanager
2.4 there is no way to register delegator for abstract factories. Is there a way to extend DoctrineResourceFactory
and use that instead of the default one? Maybe there is there a field in doctrine-connected
configuration that allows to pass factory that should be used?
You should not edit the resources extended from Doctrine Resource:
http://book.apiskeletons.com/en/latest/files.html?highlight=extend
Use listeners instead:
https://github.com/zfcampus/zf-apigility-doctrine#custom-events
You can easily inject resources into your listeners.
Indeed, that solved my problem, thanks.