A scroll with style

Exercise 2 of 6 in chapter 10 · 270 XP · 5 objectives checked by tests

Topics covered: TemplatedEmailTwig email templateurl() and path()Sending service

The confirmation scroll does go out, but Bruna finds it dull: three lines of text, not a single dragon. She wants a real scroll, laid out properly, with a link to discover the menu.

Pippin takes the opportunity to tidy up: the sending leaves the controller for a service, the scrivener (Parcheminier). Tomorrow, other scrolls will leave from somewhere other than the form, and they will all be written in the same place.

TemplatedEmail

A TemplatedEmail is an Email whose HTML content comes from a Twig template, with a context, just like a page. Symfony renders it when sending it, and also derives a text version from it, for mail clients that do not display HTML.

One difference with a page: the email is read in a mailbox, far from the website. A relative link (/menu) leads nowhere from there.

Your mission

  1. Write Parcheminier::envoyerLaConfirmation() (send the confirmation): an HTML scroll, rendered from templates/emails/confirmation.html.twig, sent to the reservation's address, with the same subject. No scroll for a reservation without an address.
  2. Complete the template: the title “Your table awaits”, the name (nom), the number of adventurers (personnes), the date (jour), and a “Discover the menu” link that works from a mailbox.
  3. The reservation form now goes through the scrivener.

To admire the result: book a table, then open the 📬 mailbox.