API / Minn\Admin / AdminPlugin

AdminPlugin final class

Minn\Admin\AdminPlugin · public/minn/src/Minn/Admin/AdminPlugin.php · 135 lines

Minn Admin's home on a site is wp-content/plugins/minn-admin: the same plugin WordPress runs, so an eject leaves the site its admin, and Minn Admin's own updates keep it current between engine releases. The engine carries the Minn Admin release of its build at minn/admin and lays it into the plugins folder the first time a new engine version serves a request: into an empty place, where it is also activated, or over an older copy, whose active state is kept; never over a newer copy, a link, or a folder under git, and never from a development checkout.

The copy served is the plugin when it is at least the engine's own and asks for no newer engine (a "Requires Minn" header); otherwise the engine's copy, which also stands in while the plugin folder is missing.

Constants and properties

constFOLDER = 'minn-admin'
constMAIN = 'minn-admin/minn-admin.php'
constOPTION = 'minn_admin_laid'

The engine version that last settled the plugin: one autoloaded option, so a request with nothing to do reads nothing more.

constKEPT = 'Minn Admin is this site\'s admin, so it cannot be deleted while Minn runs the site. Deactivate it to switch the admin off.'

Why deleting Minn Admin is refused, wherever it is asked for.

privateLOCK_TIMEOUT = 600

A lay that died midway leaves its lock behind; one older than this is taken over.

Public

staticapp(string $engineDir, string $contentDir): Minn\Admin\App#

The app a request serves, with the address its files load from.

staticsettle(string $engineDir, string $contentDir, Minn\Runtime\Options $options): void#

Once per engine version: lays the engine's copy into the plugins folder when that is due, activating it when it was not there. A copy that cannot be laid (an unwritable folder) is not retried until the next version; the engine's copy is served meanwhile. Called once the runtime has booted, so the check is a read of the autoloaded list.

staticactivated(?string $stored): ?array#

The stored active_plugins list with Minn Admin added, sorted as activation sorts it; null when it is already there.

@return list<string>|null
staticlay(string $bundle, string $target): string#

Puts the engine's copy at $target: "laid" into an empty place, "upgraded" over an older copy, "kept" when the copy there is as new or newer, "skipped" when nothing may be written (no whole plugin to lay, a link or a git checkout in the way, another lay in progress). The new copy is built beside the target and swapped in by renames, so a request never finds half a plugin.

staticservable(string $plugin, string $bundle, string $engineVersion): bool#

Whether the plugin copy is whole, at least the engine's own, and asks for no newer engine.

Internals 1

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

privateengineVersion(string $engineDir): string#