I currently have a Symfony2 DI container instance ready with the service and all its dependencies. Say, for example, I have a Car class, and it has Engine and Lights as dependencies.
In my current setup, both of these dependencies are automatically created using the setter installation when the Car object is created, but it may well be that my Car object will not need it, it is lit this time, so it clearly does not need to instantiate this dependency.
Is there a way to achieve this in Symfony DI? Thus, only if necessary by creating an instance of the Lights object? I assume that this will be some kind of proxy implementation, for example Doctrine, but as far as I saw that it is not in Symfony DI.
Chrisr
source share