Tunnels

Tunnels

A tunnel is a journey cut into steps — a sign-up, a checkout, a renewal — whose road can change with what the visitor answers. The package remembers where each visitor stands, lets them through the steps they may see, and sends them back where they belong when they try to skip ahead.

A tree of cursors

A tunnel is built as a tree, not a list. A step reached from two places is two cursors, each with its own hash and its own stored values: that is what lets a branch grow steps another one does not have, and what the way you came, shown at the end of each tunnel, is read from.

A session in the database

Opening a tunnel creates a session, which the browser session only knows by its id. It holds the values the steps store, and expires a day after the last step shown — or sooner, when that step asks for it. Expired sessions are dropped by the scheduler, every 15 minutes; completed and pending ones are kept.

Where the visitor may go

Every step decides whether it can be shown and where to send the visitor otherwise. Links and buttons are drawn with the same rules, so a link never leads to a redirect back: no next button where the road parts, no way back past a payment, nothing to go back to in a closed session.

What to look at while walking

The stepper Where you stand, what is behind, what is ahead. A gap marks where the road depends on a choice not made yet.
Behind this step Under every step, what the engine just did, and its state: the cursor, how the step completes, the session and when it expires.
The develop toolbar and the shell The Tunnels tab of the develop toolbar draws the session of this browser on the map of its tunnel; bin/console tunnels:info does the same from a shell.