class PluginManager (View source)

Plugin manager

Properties

protected $composer
protected $io
protected $globalComposer
protected $versionParser
protected $disablePlugins
protected $plugins
protected $registeredPlugins

Methods

__construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, bool $disablePlugins = false)

Initializes plugin manager

loadInstalledPlugins()

Loads all plugins from currently installed plugin packages

array
getPlugins()

Gets all currently active plugin instances

Composer|null
getGlobalComposer()

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

registerPackage(PackageInterface $package, bool $failOnMissingClasses = false)

Register a plugin package, activate it etc.

string
getPluginApiVersion()

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

addPlugin(PluginInterface $plugin)

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

null|string
getCapabilityImplementationClassName(PluginInterface $plugin, string $capability)

No description

null|Capability
getPluginCapability(PluginInterface $plugin, string $capabilityClassName, array $ctorArgs = array())

No description

getPluginCapabilities(string $capabilityClassName, array $ctorArgs = array())

No description

Details

__construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, bool $disablePlugins = false)

Initializes plugin manager

Parameters

IOInterface $io
Composer $composer
Composer $globalComposer
bool $disablePlugins

loadInstalledPlugins()

Loads all plugins from currently installed plugin packages

array getPlugins()

Gets all currently active plugin instances

Return Value

array plugins

Composer|null getGlobalComposer()

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

Return Value

Composer|null

registerPackage(PackageInterface $package, bool $failOnMissingClasses = false)

Register a plugin package, activate it etc.

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

Parameters

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

Exceptions

UnexpectedValueException

protected string getPluginApiVersion()

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

Return Value

string

addPlugin(PluginInterface $plugin)

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

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

PluginInterface $plugin plugin instance

protected null|string getCapabilityImplementationClassName(PluginInterface $plugin, string $capability)

Parameters

PluginInterface $plugin
string $capability

Return Value

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

Exceptions

RuntimeException On empty or non-string implementation class name value

null|Capability getPluginCapability(PluginInterface $plugin, string $capabilityClassName, array $ctorArgs = array())

Parameters

PluginInterface $plugin
string $capabilityClassName The fully qualified name of the API interface which the plugin may provide an implementation of.
array $ctorArgs Arguments passed to Capability's constructor. Keeping it an array will allow future values to be passed w\o changing the signature.

Return Value

null|Capability

Capability[] getPluginCapabilities(string $capabilityClassName, array $ctorArgs = array())

Parameters

string $capabilityClassName The fully qualified name of the API interface which the plugin may provide an implementation of.
array $ctorArgs Arguments passed to Capability's constructor. Keeping it an array will allow future values to be passed w\o changing the signature.

Return Value

Capability[]