Reputation: 339
I have an entity called Container
which depends on a service, DeviceService
.
I currently inject it using an Entity Listener on postLoad. However this is not being injected when just creating the plain object new Container()
.
Should I create a ContainerFactory
where I inject the service into the new object, along with the current listener, or do a smarter way exist in Symfony?
Upvotes: 4
Views: 18781
Reputation: 89
You can use Doctrine events. See : https://symfonycasts.com/screencast/api-platform-extending/post-load-listener
Upvotes: 2