In a futur webapp, I need to retreive datas from differents API (Soap/Rest/Custom...), and sometime mix results from 2, 3, or all API at the same time.
For each API, i will perform the sames actions, ex: getLastDatas, setOneData, putDatas2externalDB, etc...
In a controller, I could to something like:
$someFreshResults = $this->get('app.products')->getFreshResults($para1, $para2, $arrayOfAPI);
with $arrayOfAPI a list of 1, 2, or all API name.
As all API are different (and sometime not trivial), i think it could be revelant to declare a service by API, but a very bad and ugly idea to inject all those services inside the app.products services and loop for them with something like :
public function getFreshResults($para1, $para2, $API) {
foreach($API as $oneApi) {
oneResult = $this->get($oneAPI)->getLastDatas($para1);
... work with oneResult ...
}
}
What is the proper way to do this in a symfony app ?
Aucun commentaire:
Enregistrer un commentaire