Problem/Motivation
Create a clearer and more useable interface closer to the direction preferred in discussions in the Core issue queues.
Proposed resolution
- Remove
EmailFactoryInterfaceandEmailBuilderInterface::createParams(). - Instead, each
EmailBuilderadds a function with name and parameters appropriate to the service it provides, which is added to a new interface. For exampleUserEmailBuilderimplementsUserMailerInterface::notify(string $op, UserInterface $user). NowUserEmailBuilderhas a wider scope than before and it entirely replaces_user_mail_notify()(rather than as before replacinguser_mail(). - Register each
XXXMailerInterfacein the symfony container for auto-wiring. The code using the service now has a proper documented interface to a service which can be loaded merely by adding a constructor argument. - Add
MailerInterface::newEmail()which returns an instance ofEmailInterfacethat is in the initialisation phase. - Each
EmailBuildercalls this function and registers itself on the new email withaddProcessor()(this being handled in the base class). It then makes various calls tosetParam()and perhapssetTo(), finishing withsend(). - New function
EmailBuilderInterface::addProcessor()which adds a processor to the next email that is sent. This allows the code using the email service to customise the emails sent, and it's also useful for tests. - Create a new service tag
symfony_mailer.add_processor. The mailer adds all services with this tag to all emails. Add the tag toEmailAdjusterManager. - The Mailer and Email classes are now self-contained, without any reference to
EmailBuilderorEmailAdjuster. They are a candidate for adding to Core. - Commit to 2.x, and backport to v1.x except deprecating the code instead of removing it.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork symfony_mailer-3315446
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
elberHi I added a initial ideas to this issue please revise.
Comment #5
adamps commentedComment #6
adamps commentedComment #8
adamps commentedThanks @elber it was a good start.
Comment #11
adamps commentedComment #13
adamps commentedComment #14
adamps commented