ModeDisclosure
Corex\Config\Operations\ModeDisclosure · class · Config layer
What a proposed operations mode actually asks of the operator (spec 077, FR-006/FR-007). One answer, three consumers: the server renders the block this describes, the client swaps between blocks using the same description, and the controller validates against it. Before this, the form rendered every confirmation for every mode — a site in Development still showed the “Type PRODUCTION” field and the “I understand maintenance affects real visitors” checkbox. Being asked to acknowledge consequences that cannot occur teaches an operator that confirmations are noise, which is the lesson that makes them dangerous when they are real. Deliberately a pure description. It evaluates no readiness, checks no capability and reads no option, so the same object answers identically on the server, in a unit test with no WordPress booted, and for a mode the site is merely considering. Readiness and capability are decided by the services that own them; this only says which questions belong to which mode. OperationsMode::requiresConfirmation() already knew that production and maintenance need a confirmation. What it could not say is which confirmation — and that distinction is the whole defect: two different questions had collapsed into one boolean, so both fields were rendered whenever either applied.
Public API
Section titled “Public API”__construct(OperationsMode $modes)
Section titled “__construct(OperationsMode $modes)”confirmationFor(string $mode): string
Section titled “confirmationFor(string $mode): string”Which confirmation this mode requires — the question, not merely whether there is one.
requiresPhrase(string $mode): bool
Section titled “requiresPhrase(string $mode): bool”requiresAcknowledgement(string $mode): bool
Section titled “requiresAcknowledgement(string $mode): bool”describe(string $mode): array
Section titled “describe(string $mode): array”What this mode means, in the operator’s terms, and what it is fair to warn them about. Every line is something the code actually does. The maintenance lines in particular are verifiable against {@see MaintenanceGuard}: anonymous front-end visitors get a 503 with a Retry-After, and admin, cron, AJAX and REST contexts are never intercepted. The coming-soon lines are the rows of {@see ComingSoonDecision}, in the operator’s words. consequences is what a switch changes for visitors and for people signed in — what the operator is agreeing to. reference is how the mode works and how to leave it: true, worth having, and not something to read before every change.
describeAll(): array
Section titled “describeAll(): array”Every mode’s description, for the renderer that draws all of them and hides the inactive ones.