PluginDownloaderInterface
Where a plugin's source code comes from. The installer needs four things from a source of plugins: read a coordinate, pick a version, put the files somewhere on disk, and clean up after itself. It does not need to know that any of it happens over GitHub — and once that is true, an installer can be driven by a catalog, a private mirror, or a test double without any of them pretending to be a GitHub client. {@see \Milpa\Plugin\GitHubDownloader} is the implementation that ships with the framework.
PluginDownloaderInterface::parseSource()
abstract public function parseSource(string $source): arrayReads a coordinate into its parts: `owner/repo`, `owner/repo:^2.0`, or a full URL. Pure — no network, no disk.
Parameters
| Name | Type | Description |
|---|---|---|
| $source | string |
Throws
\InvalidArgumentException when the coordinate cannot be read
PluginDownloaderInterface::resolveVersion()
abstract public function resolveVersion(string $owner, string $repo, ?string $constraint = null): Milpa\ValueObjects\SemanticVersionThe highest published version satisfying the constraint, or the latest one when no constraint is given.
Parameters
| Name | Type | Description |
|---|---|---|
| $owner | string | |
| $repo | string | |
| $constraint | ?string |
Throws
\RuntimeException when no version satisfies the constraint
PluginDownloaderInterface::download()
abstract public function download(string $owner, string $repo, Milpa\ValueObjects\SemanticVersion $version): stringPlaces that version's files on disk and returns the directory holding them. The returned directory MUST be nested inside a scratch directory this downloader owns and nothing else uses — never a path whose parent holds anything else. The installer cleans up by removing the returned path's PARENT, so an implementation that returns, say, `/tmp/plugin` hands `/tmp` to a recursive delete. It is the one invariant a third-party source of plugins has to get right.
Parameters
| Name | Type | Description |
|---|---|---|
| $owner | string | |
| $repo | string | |
| $version | Milpa\ValueObjects\SemanticVersion |
Throws
\RuntimeException when the download or the extraction fails
PluginDownloaderInterface::cleanup()
abstract public function cleanup(string $path): voidRecursively removes a directory: either one produced by {@see self::download()} (or its owned parent), or a plugin directory the installer is replacing. Never throws — cleanup runs on failure paths, where a second exception would bury the first.
Parameters
| Name | Type | Description |
|---|---|---|
| $path | string |