API / Minn\Ops / DirectoryApi

DirectoryApi final readonly class

Minn\Ops\DirectoryApi · public/minn/src/Minn/Ops/DirectoryApi.php · 56 lines

plugins_api() and themes_api() as plugins call them and answer them (probes plugins-api, themes-api), one class for both ($kind 'plugins' or 'themes'): the arguments as an object with the reader's locale and the major.minor version beside them, through <kind>_api_args; then whatever a plugin answers through <kind>_api (a seller's own information, or an error) stands, and only when nobody answers is the directory asked, through Ops\Packages (behind the Minn update service); <kind>_api_result is handed what came back either way. A refusal is <kind>_api_failed in the directory's own words.

Uses 1

Constants and properties

privatereadonly string $kind

Promoted from the constructor.

privatereadonly Closure $filter

Promoted from the constructor.

privatereadonly Minn\Ops\Packages $packages

Promoted from the constructor.

privatereadonly string $locale

Promoted from the constructor.

privatereadonly string $version

Promoted from the constructor.

Public

new__construct(string $kind, Closure $filter, Minn\Ops\Packages $packages, string $locale, string $version)#
$filterClosure(string, mixed...): mixedapplies a filter, as apply_filters does
methodask(string $action, object|array $args): mixed#

The answer for an action (plugin_information, query_themes, ...): an object, a WP_Error, or what a plugin returned.

Internals 2

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

privatedirectory(string $action, array $request): object#
$requestarray<string, mixed>
privateunexpected(string $body): WP_Error#

An answer that is not JSON. wordpress.org words an unknown theme action as JSON to WordPress but as a paragraph to anyone else (the update service), so the paragraph is read as the refusal WordPress would have been given; anything else is the reference's own message for an answer it cannot read, the body kept as its data.