Problem/Motivation
OrchestraNotificationEvent is the channel-neutral contract for notifications: resolved recipients plus structured params, delivered by whichever channel is enabled. There is currently no way for a dispatcher to attach a file (a generated PDF, an ICS invite, a receipt), so a channel cannot deliver one.
The concrete driver is the Yoyaku ticket submodule (yoyaku #3611638): on order confirmation it generates a PDF ticket that should ride along on the existing confirmation email rather than forcing a second, separate email. An order can hold several tickets (one per booked place), so a notification must be able to carry multiple attachments, one per ticket.
Proposed resolution
Add a neutral attachments payload to OrchestraNotificationEvent and have the shipped channels honor it.
- New
NotificationAttachmentvalue object (@api): filename, mimeType, and one of content (raw bytes) or uri (a stream-wrapper URI), so a producer can pass either an in-memory blob or a file. - New trailing
array $attachments = []constructor argument onOrchestraNotificationEvent, a list ofNotificationAttachment. Being a list, one notification can carry many files (one per ticket). It is appended last, so existing dispatchers are unaffected. - orchestra_mail: pass the attachments through so hook_mail sets the message attachments (the de-facto convention honored by Symfony Mailer and Mime Mail). The default PHP mail backend does not send attachments; this is a mail-system capability, not an Orchestra one.
- orchestra_easy_email: map the attachments onto the Easy Email entity before send.
Remaining tasks
- Implement the value object and the event change.
- Honor attachments in both channels.
- Unit and kernel coverage for both channels: attachment present, empty default, uri versus content, and multiple attachments.
API changes
OrchestraNotificationEvent::__construct()gains a trailingarray $attachments = []argument (backward compatible).- New @api
NotificationAttachmentvalue object.
Issue fork orchestra-3612558
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 #3
mably commentedComment #5
mably commented