There is a problem in the tavern: the traveler receives “Your table awaits” as soon as they fill in the form. But nothing is confirmed yet: Gorm can still turn the reservation down, on a fully booked feast night. And when he cancels a reservation, the traveler knows nothing about it.
The confirmation scroll must go out when the tavern confirms. And a cancellation scroll, when it cancels.
Workflow events
On every transition, the workflow announces each of its steps:
guard: is the transition allowed?leave: the object leaves its place;transition: it is on its way;enter, thenentered: it has arrived at its new place;completed: it is over;announce: for each transition that is now possible.
Each event also exists per workflow, per transition or per place (workflow.reservation.entered.confirmed). Reacting to a status change means listening to the right one.
The benefit: whether the reservation is confirmed from the reservation book, a command or the API, the scroll goes out.
Your mission
- When a reservation arrives at
confirmed, the confirmation scroll goes out. - When it arrives at
canceled, a cancellation scroll goes out: subject “Your reservation at the Drunken Dragon is canceled”, with the title “Your reservation is canceled”, the name, the date, and a “Book another table” link. WriteParcheminier::envoyerLAnnulation()(send the cancellation) and its template,emails/annulation.html.twig. - Canceling an already confirmed reservation sends only the cancellation; honoring sends nothing.
- The reservation form no longer sends the confirmation.
Write the listeners in ParcheminsDuRegistre (the reservation book's scrolls). To try it out: log in with gorm@drunken-dragon.me / barrel, confirm and cancel reservations in the reservation book, then open the 📬 mailbox.