On Mondays, Bruna goes to the market and Gorm counts the barrels: the tavern is closed. Until now, Pippin hung a sign on the door, but the website keeps taking reservations. We need a rule that applies to every dining room page, without touching each controller.
Kernel events
For every request, Symfony announces the steps of its work as events: kernel.request (the request arrives), kernel.controller, kernel.response, kernel.exception… Any service can listen to them. That's how the router, the firewall and the profiler work.
And when a kernel.request listener provides a response itself, Symfony does not call the controller.
Your mission
Complete the FermeLeLundi (closed on Mondays) listener:
- on Mondays, the dining room pages (the routes in
SALLE, the dining room) respond 503 with thefermeture.html.twig(closing) page; - on the other days, nothing changes;
- the kitchen, the guild API and the login page stay open;
- an unknown page stays a 404.
Read the time from the clock ($horloge) received in the constructor, not with new \DateTimeImmutable(): that's what lets the tests pick the day. In development, Pippin even stopped the clock on a Monday at noon (config/packages/horloge.yaml): the preview must show the closing page.