I need to remove some entities from a collection of entities, to do so, I call 4 services one after the other to remove the entites who don't match some filters.
class MainService()
{
public function removeEntities($collection)
{
$collection = $this->subServiceA->removeEntities($collection);
$collection = $this->subServiceB->removeEntities($collection);
$collection = $this->subServiceC->removeEntities($collection);
$collection = $this->subServiceD->removeEntities($collection);
return $collection;
}
}
I think that decorator, chain of responsibility or observer can handle this case but I don't know which one suit it the best.
Aucun commentaire:
Enregistrer un commentaire