A reservation has a life: requested by a traveler, confirmed by the tavern, then honored when the evening comes. Unless someone cancels it in the meantime. Today, nothing prevents it from being honored without having been confirmed, or canceled after the meal.
Pippin has added a statut (status) to reservations. Rather than scattering if ($statut === …) everywhere, the tavern will describe this life cycle once, and let Symfony enforce it.
The Workflow component
A workflow describes places (the possible states) and transitions (the allowed moves from one place to another). When an object can only be in one place at a time, it is a state machine (state_machine). The workflow knows:
- where the object stands (
getMarking()); - what can be done (
can(),getEnabledTransitions()); - how to move the object forward (
apply()), and refuses what is not allowed.
Your mission
-
In
config/packages/workflow.yaml, describe thereservationstate machine:Transition from to confirmrequestedconfirmedhonorconfirmedhonoredcancelrequestedorconfirmedcanceledA new reservation starts at
requested, and the place is stored in thestatutproperty. -
Reservations from the website and those from the guilds (the API) are saved as
requested.
In the console, workflow:dump reservation --dump-format=mermaid describes your machine as a diagram.