API / Minn\Rest / PluginsController

PluginsController final readonly class

Minn\Rest\PluginsController · public/minn/src/Minn/Rest/PluginsController.php · 243 lines

wp/v2 plugins: what sits in wp-content/plugins, in the reference's shape. Minn extensions (a minn.json manifest) are listed alongside the WordPress plugins the folder still holds; the engine runs the former and only records the latter's stored state. Activation writes the same options the reference and the extension loader read; files are never installed or deleted from here.

Used by 1

Constants and properties

privatereadonly Minn\Content\Site $site

Promoted from the constructor.

privatereadonly Minn\Content\Inventory $inventory

Promoted from the constructor.

privatereadonly Minn\Extension\Loader $extensions

Promoted from the constructor.

privatereadonly Minn\Rest\RestUrl $url

Promoted from the constructor.

privatereadonly Minn\Rest\Caller $caller

Promoted from the constructor.

privatereadonly Minn\Ops\Packages $packages

Promoted from the constructor.

Public

new__construct(Minn\Content\Site $site, Minn\Content\Inventory $inventory, Minn\Extension\Loader $extensions, Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller, Minn\Ops\Packages $packages)#
methodlist(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/plugins (cap activate_plugins)#

The plugins list, optionally by status.

methodinstall(Minn\Http\Request $request): Minn\Http\ResponsePOST /wp/v2/plugins (cap activate_plugins)#

Installs a directory plugin by slug, optionally activating it; answers 201 with the item.

methodsingle(Minn\Http\Request $request, string $plugin): Minn\Http\ResponseGET /wp/v2/plugins/{plugin:[^.\/]+(?:\/[^.\/]+)?} (cap activate_plugins)#

One plugin.

methodupdate(Minn\Http\Request $request, string $plugin): Minn\Http\ResponsePUT /wp/v2/plugins/{plugin:[^.\/]+(?:\/[^.\/]+)?} (cap activate_plugins)POST /wp/v2/plugins/{plugin:[^.\/]+(?:\/[^.\/]+)?} (cap activate_plugins)PATCH /wp/v2/plugins/{plugin:[^.\/]+(?:\/[^.\/]+)?} (cap activate_plugins)#

Activates or deactivates a plugin.

methoddelete(Minn\Http\Request $request, string $plugin): Minn\Http\ResponseDELETE /wp/v2/plugins/{plugin:[^.\/]+(?:\/[^.\/]+)?} (cap activate_plugins)#

Deletes an inactive plugin.

staticshape(string $relative, string $path, array $headers, string $status): array#

A WordPress plugin's item from its headers, as the reference's controller shapes one (the runtime's WP_REST_Plugins_Controller shapes through here too): the headers translated and cut to the allowed markup once for the fields and once more, marked up, for the rendered description.

$headersarray<string, mixed>the plugin's headers, as get_plugins() holds them
@return array<string, mixed>

Internals 9

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

privateitems(): array#
@return list<array>
privatefind(string $plugin): array#

One plugin's item, built alone: an item reads (and loads the text domain of) only its own plugin.

privatestatusOf(string $plugin): string#

Whether a plugin is active, read without building its item (nothing translated, no text domain loaded).

privatemanifestFor(string $plugin): ?Minn\Extension\Manifest#
privateextensionItem(Minn\Extension\Manifest $manifest, bool $active): array#
privatepluginItem(string $relative, string $path, bool $active): array#

A WordPress plugin as the reference's item shows it: its headers read, translated and cut to the allowed markup once for the fields and once more, marked up, for the rendered description (probe plugin-data).

privatelinks(string $key): array#
privateextensionKey(Minn\Extension\Manifest $manifest): string#
privaterefuse(?Minn\Runtime\Refusal $refusal): void#

An activation the plugin refused, as the reference's REST answer carries it: HTTP 500, the refusal's own data kept beside.