I'm trying to implement Uncle Bob's Clean Architecture:
Everything is ok except the UseCases/Interactors. I need to register a user, so I need RegisterUser UseCase. In the concrete interactor I implement the RegisterUser use case which just create User entity and hash its password with PasswordBroker port.
After user creation I need to send a verification email. To do this I need to use framework's component. And there are two main problems.
- I think it has no sense to write port for the Mail service, because this port would be just a huge copy/paste abstraction of a framework service
- Interactor cannot send an email after user creation, because User finally would be stored after Doctrine
flush()inside controller. There is a risk, when we've sent an email, but User wasn't stored in a DB. It must be consistent.
What's the best approach in this case?
I think we need some kind of port that relates to the concrete use case, this port will be called in the end of use case and implemented in Application Layer where framework's Mailer and Doctrine are available.
