Dispatch an event before/after building the mailjet Message to permit other module to alter the message sent.

CommentFileSizeAuthor
#12 2937885-12.patch4.61 KBflocondetoile
Command icon 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

flocondetoile created an issue. See original summary.

darvanen’s picture

Happy 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?

flocondetoile’s picture

Title: Dispatch an event before/after building the mailjet Message » Dispatch an event after building the mailjet Message

Yes, after should be sufficient.

darvanen’s picture

Status: Active » Needs review

This should do the trick.

  • darvanen authored ebbb8db on 8.x-1.x
    Issue #2937885 by darvanen, flocondetoile: Dispatch an event after...
flocondetoile’s picture

Status: Needs review » Fixed

Thanks.

flocondetoile’s picture

I 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.

darvanen’s picture

My pleasure.

And, I suppose... to alter the incoming message array?

flocondetoile’s picture

Yes. 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)

darvanen’s picture

Status: Fixed » Needs review

No need for a new issue, this only took a few minutes.

flocondetoile’s picture

StatusFileSize
new4.61 KB

with a patch

flocondetoile’s picture

And as the event dispatcher used is only compatible with Drupal 9, bumping the core requirement to ^9.

  • flocondetoile authored 7935740 on 8.x-1.x
    Issue #2937885 by darvanen, flocondetoile: Dispatch an event after...
flocondetoile’s picture

Status: Needs review » Fixed

Thanks

darvanen’s picture

I'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.

  • flocondetoile authored 603dc72 on 8.x-1.x
    Issue #2937885 by darvanen, flocondetoile: Dispatch an event after...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.