Documentation

PluginManager
in package

Plugin manager

Tags
author

Nils Adermann naderman@naderman.de

author

Jordi Boggiano j.boggiano@seld.be

Table of Contents

$composer  : mixed
$disablePlugins  : mixed
$globalComposer  : mixed
$io  : mixed
$plugins  : mixed
$registeredPlugins  : mixed
$versionParser  : mixed
$classCounter  : mixed
__construct()  : mixed
Initializes plugin manager
addPlugin()  : mixed
Adds a plugin, activates it and registers it with the event dispatcher
getGlobalComposer()  : Composer|null
Gets global composer or null when main composer is not fully loaded
getPluginCapabilities()  : array<string|int, Capability>
getPluginCapability()  : null|Capability
getPlugins()  : array<string|int, mixed>
Gets all currently active plugin instances
loadInstalledPlugins()  : mixed
Loads all plugins from currently installed plugin packages
registerPackage()  : mixed
Register a plugin package, activate it etc.
getCapabilityImplementationClassName()  : null|string
getPluginApiVersion()  : string
Returns the version of the internal composer-plugin-api package.
collectDependencies()  : array<string|int, mixed>
Recursively generates a map of package names to packages for all deps
getInstallPath()  : string
Retrieves the path a package is installed to.
loadRepository()  : mixed
Load all plugins and installers from a repository
lookupInstalledPackage()  : PackageInterface|null
Resolves a package link to a package in the installed pool

Properties

$registeredPlugins

protected mixed $registeredPlugins = array()

Methods

addPlugin()

Adds a plugin, activates it and registers it with the event dispatcher

public addPlugin(PluginInterface $plugin) : mixed

Ideally plugin packages should be registered via registerPackage, but if you use Composer programmatically and want to register a plugin class directly this is a valid way to do it.

Parameters
$plugin : PluginInterface

plugin instance

Return values
mixed

getGlobalComposer()

Gets global composer or null when main composer is not fully loaded

public getGlobalComposer() : Composer|null
Return values
Composer|null

getPluginCapabilities()

public getPluginCapabilities(string $capabilityClassName[, array<string|int, mixed> $ctorArgs = array() ]) : array<string|int, Capability>
Parameters
$capabilityClassName : string

The fully qualified name of the API interface which the plugin may provide an implementation of.

$ctorArgs : array<string|int, mixed> = array()

Arguments passed to Capability's constructor. Keeping it an array will allow future values to be passed w\o changing the signature.

Return values
array<string|int, Capability>

getPluginCapability()

public getPluginCapability(PluginInterface $plugin, string $capabilityClassName[, array<string|int, mixed> $ctorArgs = array() ]) : null|Capability
Parameters
$plugin : PluginInterface
$capabilityClassName : string

The fully qualified name of the API interface which the plugin may provide an implementation of.

$ctorArgs : array<string|int, mixed> = array()

Arguments passed to Capability's constructor. Keeping it an array will allow future values to be passed w\o changing the signature.

Return values
null|Capability

getPlugins()

Gets all currently active plugin instances

public getPlugins() : array<string|int, mixed>
Return values
array<string|int, mixed>

plugins

loadInstalledPlugins()

Loads all plugins from currently installed plugin packages

public loadInstalledPlugins() : mixed
Return values
mixed

registerPackage()

Register a plugin package, activate it etc.

public registerPackage(PackageInterface $package[, bool $failOnMissingClasses = false ]) : mixed

If it's of type composer-installer it is registered as an installer instead for BC

Parameters
$package : PackageInterface
$failOnMissingClasses : bool = false

By default this silently skips plugins that can not be found, but if set to true it fails with an exception

Tags
throws
UnexpectedValueException
Return values
mixed

getCapabilityImplementationClassName()

protected getCapabilityImplementationClassName(PluginInterface $plugin, string $capability) : null|string
Parameters
$plugin : PluginInterface
$capability : string
Tags
throws
RuntimeException

On empty or non-string implementation class name value

Return values
null|string

The fully qualified class of the implementation or null if Plugin is not of Capable type or does not provide it

getPluginApiVersion()

Returns the version of the internal composer-plugin-api package.

protected getPluginApiVersion() : string
Return values
string

collectDependencies()

Recursively generates a map of package names to packages for all deps

private collectDependencies(Pool $pool, array<string|int, mixed> $collected, PackageInterface $package) : array<string|int, mixed>
Parameters
$pool : Pool

Package pool of installed packages

$collected : array<string|int, mixed>

Current state of the map for recursion

$package : PackageInterface

The package to analyze

Return values
array<string|int, mixed>

Map of package names to packages

getInstallPath()

Retrieves the path a package is installed to.

private getInstallPath(PackageInterface $package[, bool $global = false ]) : string
Parameters
$package : PackageInterface
$global : bool = false

Whether this is a global package

Return values
string

Install path

loadRepository()

Load all plugins and installers from a repository

private loadRepository(RepositoryInterface $repo) : mixed

Note that plugins in the specified repository that rely on events that have fired prior to loading will be missed. This means you likely want to call this method as early as possible.

Parameters
$repo : RepositoryInterface

Repository to scan for plugins to install

Tags
throws
RuntimeException
Return values
mixed

lookupInstalledPackage()

Resolves a package link to a package in the installed pool

private lookupInstalledPackage(Pool $pool, Link $link) : PackageInterface|null

Since dependencies are already installed this should always find one.

Parameters
$pool : Pool

Pool of installed packages only

$link : Link

Package link to look up

Return values
PackageInterface|null

The found package

Search results