I'm using domain driven design.
I've got the following model (classes):
- User
- UserDAO
- UserRepository
- UserService
I know that UserService is supposed to contain all the corresponding application logic. So I got methods like signUp()
, logIn()
and update()
in there.
My signUp()
method, signs a user up, but throws a PDO exception when the email UNIQUE constraint has been violated. Now, since exceptions are for exceptional errors only and bad for control flow my question is:
Is an emailExist()
method allowed to be in a UserService class?
So I can call that first in my controller (so I can report back with a form error if the email already exist), before actually signing a user up. I know such method actually belongs in the data mapper, but since they aren't supposed to be used directly in controllers I thought about having it added to my UserService class and from there map it to my repository's findByEmail()
method.