PluginsController final readonly class
Minn\Rest\PluginsController · public/minn/src/Minn/Rest/PluginsController.php · 292 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.
Uses 29 (show)
Constants and properties
| private | LIST_ARGS = array ( 'search' => array ( 'description' => 'Limit results to those matching a string.', 'type' => 'string', 'required' => false, ), 'status' => array ( 'description' => 'Limits results to plugins with the given status.', 'type' => 'array', 'items' => array ( 'type' => 'string', 'enum' => array ( 0 => 'inactive', 1 => 'active', ), ), 'required' => false, ), ) | Read by list(): the search and the statuses it narrows to. |
| private | readonly Minn\Content\Site $site | Promoted from the constructor. |
| private | readonly Minn\Content\Inventory $inventory | Promoted from the constructor. |
| private | readonly Minn\Extension\Loader $extensions | Promoted from the constructor. |
| private | readonly Minn\Rest\RestUrl $url | Promoted from the constructor. |
| private | readonly Minn\Rest\Caller $caller | Promoted from the constructor. |
| private | readonly 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)# | ||||
| method | list(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/plugins (cap activate_plugins)# | The plugins list, narrowed by status and by a search when one is asked. | |||
| method | install(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. | |||
| method | single(Minn\Http\Request $request, string $plugin): Minn\Http\ResponseGET /wp/v2/plugins/{plugin:[^.\/]+(?:\/[^.\/]+)?} (cap activate_plugins)# | One plugin; the refusal is named for the one, as on the reference. | |||
| method | update(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. | |||
| method | delete(Minn\Http\Request $request, string $plugin): Minn\Http\ResponseDELETE /wp/v2/plugins/{plugin:[^.\/]+(?:\/[^.\/]+)?} (cap activate_plugins)# | Deletes an inactive plugin. | |||
| static | shape(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.
@return array<string, mixed> |
Internals 10
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | mentions(array $searched, string $search): bool# | Whether a search names a plugin: found, letter case kept, in its file or in one of its headers as written (probe: the reference's list).
| |||
| private | items(): array# | Every plugin's item, with the text a search reads for it: a WordPress plugin's file and headers as written, an extension's key and fields. @return list<array{0: array<string, mixed>, 1: list<string>}> | |||
| private | find(string $plugin): array# | One plugin's item, built alone: an item reads (and loads the text domain of) only its own plugin. | |||
| private | statusOf(string $plugin): string# | Whether a plugin is active, read without building its item (nothing translated, no text domain loaded). | |||
| private | manifestFor(string $plugin): ?Minn\Extension\Manifest# | ||||
| private | extensionItem(Minn\Extension\Manifest $manifest, bool $active): array# | ||||
| private | pluginItem(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). | |||
| private | links(string $key): array# | ||||
| private | extensionKey(Minn\Extension\Manifest $manifest): string# | ||||
| private | refuse(?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. |
Nothing matches.