I have the following patterns in PHP and I would like to implement it in order to take advantage of the service provider and dependency injection process in laravel.
Explanations :
I'm building a synchronization app and I want it to be very flexible in order to add others platforms in the future. To do so, I have platforms that are implementing and extending interfaces and abstract classes. As the synchronization process doesn't depend on how data are retrieved and pushed then I'm just using the interface "iPlatform" to access to DataPusher and DataRetriever implementations.
All my concrete classes are singleton (platformA, DataPusherA, DataRetrieverA... same for B). "PlatformB" and "PlatformA" are implementing static methods to access to DataRetreiver and DataPusher instances for each platforms.
I thought about contextual Binding to replace these Platform A and B (which are kind of accessors to concrete methods in DataPusherA/RetrieverA and B actually). But I still have some difficulties to understand how to take advantage of the laravel framework to correctly implement that schema.
I'm open to any suggestions to change that schema (if I'm wrong about the pattern used) or if you have some advice to implement it. Thank you very much for your help.
Ps: Sorry if I made some English mistakes, it's not my natural language.
Aucun commentaire:
Enregistrer un commentaire