Dispatch an event before/after building the mailjet Message to permit other module to alter the message sent.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 2937885-12.patch | 4.61 KB | flocondetoile |
Issue fork mailjet_api-2937885
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 #2
darvanenHappy to do this, shouldn't take long, have done it before.
I assume this would go in \Drupal\mailjet_api\MailjetApiHandler::buildMessagesBody ?
I don't see a lot of value in a pre-create event but an alter event with the finished $mailjet_message could be useful.
Thoughts?
Comment #3
flocondetoileYes, after should be sufficient.
Comment #5
darvanenThis should do the trick.
Comment #7
flocondetoileThanks.
Comment #8
flocondetoileI remenber why the before event could be useful. If you want to set templateID and/or variables with an Event subscriber rather than a hook_mail or hook_mail_alter. This could be added in another issue.
Comment #9
darvanenMy pleasure.
And, I suppose... to alter the incoming message array?
Comment #10
flocondetoileYes. Before the check of an existing templateID in the message array, as this condition the building of the array (templateId and variables or the Body)
Comment #11
darvanenNo need for a new issue, this only took a few minutes.
Comment #12
flocondetoilewith a patch
Comment #13
flocondetoileAnd as the event dispatcher used is only compatible with Drupal 9, bumping the core requirement to ^9.
Comment #15
flocondetoileThanks
Comment #16
darvanenI'm sorry I didn't see the messages on the MR or I would have responded. Drupal doesn't email us unless there's a comment directly on the issue :/
Thanks for sorting it out.