API / Minn\Cli / PackageInstaller

PackageInstaller final readonly class

Minn\Cli\PackageInstaller · public/minn/src/Minn/Cli/PackageInstaller.php · 142 lines

Puts a theme or a plugin on disk for `wp theme install` and `wp plugin install`: a directory slug, a local zip, or a zip URL, saying along the way what WP-CLI says. The two kinds differ only in their words, in where they live, and in a plugin being allowed to be a single file.

Constants and properties

privatereadonly Minn\Ops\Packages $packages

Promoted from the constructor.

privatereadonly string $kind

Promoted from the constructor.

privatereadonly string $invalidSlug

Promoted from the constructor.

privatereadonly string $notFound

Promoted from the constructor.

Public

new__construct(Minn\Ops\Packages $packages, string $kind, string $invalidSlug, string $notFound)#
staticthemes(Minn\Ops\Packages $packages): self#

The installer `wp theme install` uses.

staticplugins(Minn\Ops\Packages $packages): self#

The installer `wp plugin install` uses.

methodinstall(string $source, bool $force, string $version): array#

One source onto disk: the folder when it is there afterwards (put there now, or already there), null when it could not be installed, and whether this call put it there.

@return array{0: ?string, 1: bool}

Internals 4

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

privatefromDirectory(string $slug, array $info, bool $force, string $version, bool $existed): array#

A directory release (from the Minn update service) onto disk, replacing an installed copy when forced.

$infoarray<string, mixed>the directory's answer for the slug
@return array{0: ?string, 1: bool}
privatearchive(string $source, bool $force): array#

A zip from a URL or a local path, unpacked into place.

@return array{0: ?string, 1: bool}
privatepresent(string $dest): bool#

Whether something of this kind is already at the path (a plugin may be a single file beside it).

privaterefuse(string $source, string $reason): array#

The two warnings WP-CLI gives for a source it could not install.

@return array{0: null, 1: false}