Open weierophinney opened 4 years ago
REST resource is created via container (service manager, if it is there defined) or directly: https://github.com/zfcampus/zf-rest/blob/master/src/Factory/RestControllerFactory.php#L117-L121 If you want inject something intro REST resource you can define your own factory for the resource and inject whatever you want.
Originally posted by @michalbundyra at https://github.com/zfcampus/zf-apigility/issues/184#issuecomment-269323820
Yes, but my ResourceFactory is not called or if I put a "exit" inside file, the php continues.
:'( I cloned apigility default project.
Originally posted by @luqezman at https://github.com/zfcampus/zf-apigility/issues/184#issuecomment-269326767
I just cloned the project, I created the service in apigility admin but ResourceFactory is never called or used.
Originally posted by @luqezman at https://github.com/zfcampus/zf-apigility/issues/184#issuecomment-269327409
Did you add to your configuration:
'service_manager' => [
'factories' => [
YourApi\V1\Rest\YourService\Resource::class => YourResourceFactory::class,
],
],
?
You can use also abstract factory if you want, or the same factory for multiple resources.
Originally posted by @michalbundyra at https://github.com/zfcampus/zf-apigility/issues/184#issuecomment-269329290
No I didn't. But I need to include this config inside module config or in global config?
Originally posted by @luqezman at https://github.com/zfcampus/zf-apigility/issues/184#issuecomment-269329421
Yeah Nice, it works like a charm. Big thanks dude <3
Originally posted by @luqezman at https://github.com/zfcampus/zf-apigility/issues/184#issuecomment-269329658
But I need to include this config inside module config or in global config?
Doesn't matter. If this is just for one module it should be in module.config.php. If this is a global configuration for your application (applied for multiple modules) than it can be in global config.
Originally posted by @michalbundyra at https://github.com/zfcampus/zf-apigility/issues/184#issuecomment-269329659
You can close this issue and a lot of people are searching for this in "google" or "stackoverflow".
Big thanks and HNY ;)
Originally posted by @luqezman at https://github.com/zfcampus/zf-apigility/issues/184#issuecomment-269330440
Tell me one thing if you can help me:
How can I get a Factory/Service inside a resource?
Originally posted by @luqezman at https://github.com/zfcampus/zf-apigility/issues/184