API / Minn / Engine

Engine final readonly class

Minn\Engine · public/minn/src/Minn/Engine.php · 335 lines

The engine's front door. An unmodified wp-config.php ends by requiring wp-settings.php, which is the engine's own boot file; it hands off here. REST is dispatched first (from the path or from ?rest_route=), then the admin, the login endpoint, and finally the public site.

Constants and properties

constWP_VERSION = '7.1.3'

The WordPress release whose contracts the runtime speaks; wp-includes/version.php says the same.

privatereadonly string $version

Promoted from the constructor.

privatereadonly string $engineDir

the minn/ folder: the engine's own files (assets, data, the admin bundle)

Promoted from the constructor.

Public

new__construct(string $version, string $engineDir)#
methodserve(): void#

The front door: answer the request that arrived and send it. This is the only place the engine touches the world, so everything under it is a function of a request, callable more than once in a process.

methodanswer(Minn\Http\Request $request): Minn\Http\Response#

The response for one request, whatever happens: a database that cannot be reached, salts that are not set, or a failure anywhere underneath, each answered in the language the request asked in.

Internals 9

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privaterestRoute(Minn\Http\Request $request): ?string#

The REST route a request names, in the path or in ?rest_route=, or null when it is not a REST request.

privatebootRuntimeForRest(Minn\Context $context, Minn\Rest\Api $api, string $route): void#

The WordPress runtime for a REST request: the caller the REST layer resolved is the reader, plugins load, and rest_api_init fires so their routes answer after the engine's own.

privaterecheckNonce(Minn\Rest\Api $api, Minn\Runtime\Runtime $runtime): void#

A plugin's nonce lifetime (nonce_life) is heard only once plugins load: a cookie caller's nonce is checked again under it, as the reference checks it. A caller the default lifetime refused was nobody while plugins loaded; when the plugin's lifetime proves the nonce, that user reads the request from here (unless plugin code named someone).

privateadoptSettledUser(Minn\Rest\Api $api, Minn\Runtime\Runtime $runtime): void#

The user plugin code settled (determine_current_user) as the REST caller, as the reference's cookie check leaves it: a request a plugin signs in by its own token is that user; a sign-in cookie vouches only for its own user (another one fails its nonce, and without a nonce the request is nobody, plugin code included).

privatemarkThemedRequest(Minn\Http\Request $request): void#

WordPress's index.php says its requests use themes before any plugin loads; its own scripts (sign-in, the admin, cron, XML-RPC) do not, and neither does Minn Admin (probe load-remaining).

privatearmRecoveryPause(Minn\Db $db, Minn\Http\Request $request): void#

With the database in hand, a fatal during boot can be blamed on the extension it came from; the second inside ten minutes pauses it, so the next request comes back without it. The window in which this applies is opened by Plugins::load. Only a request that carries nothing a visitor chose counts: an extension that fails on some input fails for that input alone, and a visitor could otherwise pause it for everyone with two requests.

privateplain(Minn\Http\Request $request): bool#

Whether a request carries nothing a visitor chose but its path: a GET or HEAD with no query, body, upload or cookie.

privatehandle(Minn\Db $db, Minn\Http\Request $request): Minn\Http\Response#
privatefrontPipeline(Minn\Context $context, Minn\Http\Request $request, Minn\Runtime\Runtime $runtime, Minn\Content\Users $users, Minn\Auth\Cookie $cookie, Minn\Auth\Authenticator $authenticator, Minn\Admin\App $app, mixed $session, Minn\Front\Resolver $resolver, Minn\Front\Permalinks $permalinks, ?Minn\Theme\Theme $theme, ?Minn\Theme\ClassicTheme $classicTheme): Minn\Http\Response#

The themed front, admin app, and probe pipeline; split out so a mid-request ServeLogin signal can unwind it cleanly.