I'm working on a service that administer users on other services(API calls). To simplify the adding of services I've created an interface (ServiceInterface) that every service has to implement. The interface has some functions such as newUser($input), removeUser($input), editUser($input)... The input is an array of all the informations that are needed to call an API (login, firstname,..). Basically the interface is a CRUD for users, for groups(users belongs to groups) and for permissions(users have a permission for a group).
The goal is to match the API calls with the actions done on my service. Example : When I create a group on my service, I would like to create it on all the services that implements the interface. When I create a user on my service, I would like to create the same user only on services I gave him access. When I add a permission to a user on my service, I would like to add the same permission on the same user for a targeted service. As you can see, depending on the action, the "protocol" is different.
What I would like to do is to wrap this protocol. I don't want to see this logic into my current code(searching for the services the user has access, which permission belongs to which service,...).
The only idea I have (and I don't really like it) is to create a "Helper" class to handle all the logic. In my code that creates a group I would just do something like that : MyHelper::newGroup($group,..). When I create a new user i would do something like MyHelper::newUser($login,$firstname,...),...
Do you have a better idea to wrap all this different logic more OOP ?
Thanks.
Aucun commentaire:
Enregistrer un commentaire