Today i updated my project and i got this warning :
Deprecated: ServiceManagerAwareInterface is deprecated and will be removed in version 3.0, along with the ServiceManagerAwareInitializer. Please update your class X to remove the implementation, and start injecting your dependencies via factory instead
I have some main Base
classes that implements the ServiceManagerAwareInterface
and multiple classes that extends these base classes.
So is it a good practice to create on extra factory class for each of these classes ? or is it better to use 1 AbstractFactory for each module and initiate the classes in there ?
Dose using the AbstractFactory impact performance ?
Whats the best practice for injecting a single(or 2) shared dependency in many classes?
UPDATE : Even tho that i accepted @AlexP's answer but i have some concerns about providing dependencies throw constructor. Imagine this scenario : I have a controller with couple of actions, lest say ActionA needs ServiceZ and ActionB needs ServiceY and ServiceX, and ServiceX is also depends on ServiceM and ServiceN. Now every time i am calling ActionA my controller in initiated with all of these services, but ActionA only needs 1 service where my controller is loaded with 5 services.... is this a good practice ? is this the right way do to it ? wouldn't this have bad performance, since on every request services are being initiated that we won't use at all during that request ?
Right now i am allowing each service/controller to take care of its own needs and load services when it needs them.
This way i won't have to initiate multiple services that i wont use and i don't need o know the services dependencies to use them. I know this is not accepted as best practice but the code is clean and i prefer to sacrifice "Best Practice" to have better performance.
Appreciate anyone's input on this.