PHP Class Wikimedia\Composer\MergePlugin

When installed, this plugin will look for a "merge-plugin" key in the composer configuration's "extra" section. The value of this setting can be either a single value or an array of values. Each value is treated as a glob() pattern identifying additional composer.json style configuration files to merge into the configuration for the current compser execution. The "require", "require-dev", "repositories", "extra" and "suggest" sections of the found configuration files will be merged into the root package configuration as though they were directly included in the top-level composer.json file. If included files specify conflicting package versions for "require" or "require-dev", the normal Composer dependency solver process will be used to attempt to resolve the conflict. Specifying the 'replace' key as true will change this default behaviour so that the last-defined version of a package will win, allowing for force-overrides of package defines. By default the "extra" section is not merged. This can be enabled with the 'merge-extra' key by setting it to true. In normal mode, when the same key is found in both the original and the imported extra section, the version in the original config is used and the imported version is skipped. If 'replace' mode is active, this behaviour changes so the imported version of the key is used, replacing the version in the original config.
Author: Bryan Davis ([email protected])
Inheritance: implements Composer\Plugin\PluginInterface, implements Composer\EventDispatcher\EventSubscriberInterface
Mostra file Open project: wikimedia/composer-merge-plugin Class Usage Examples

Protected Properties

Property Type Description
$composer Composer\Composer
$loaded string[] Files that have already been fully processed
$loadedNoDev string[] Files that have already been partially processed
$logger Wikimedia\Composer\Logger
$state Wikimedia\Composer\Merge\PluginState

Public Methods

Method Description
activate ( Composer\Composer $composer, Composer\IO\IOInterface $io )
getSubscribedEvents ( )
onDependencySolve ( Composer\Installer\InstallerEvent $event ) Handle an event callback for pre-dependency solving phase of an install or update by adding any duplicate package dependencies found during initial merge processing to the request that will be processed by the dependency solver.
onInit ( Composer\EventDispatcher\Event $event ) Handle an event callback for initialization.
onInstallUpdateOrDump ( Composer\Script\Event $event ) Handle an event callback for an install, update or dump command by checking for "merge-plugin" in the "extra" data and merging package contents if found.
onPostInstallOrUpdate ( Composer\Script\Event $event ) Handle an event callback following an install or update command. If our plugin was installed during the run then trigger an update command to process any merge-patterns in the current config.
onPostPackageInstall ( Composer\Installer\PackageEvent $event ) Handle an event callback following installation of a new package by checking to see if the package that was installed was our plugin.

Protected Methods

Method Description
mergeFile ( Composer\Package\RootPackageInterface $root, string $path ) Read a JSON file and merge its contents
mergeFiles ( array $patterns, boolean $required = false ) Find configuration files matching the configured glob patterns and merge their contents with the master package.

Method Details

activate() public method

public activate ( Composer\Composer $composer, Composer\IO\IOInterface $io )
$composer Composer\Composer
$io Composer\IO\IOInterface

getSubscribedEvents() public static method

public static getSubscribedEvents ( )

mergeFile() protected method

Read a JSON file and merge its contents
protected mergeFile ( Composer\Package\RootPackageInterface $root, string $path )
$root Composer\Package\RootPackageInterface
$path string

mergeFiles() protected method

Find configuration files matching the configured glob patterns and merge their contents with the master package.
protected mergeFiles ( array $patterns, boolean $required = false )
$patterns array List of files/glob patterns
$required boolean Are the patterns required to match files?

onDependencySolve() public method

Handle an event callback for pre-dependency solving phase of an install or update by adding any duplicate package dependencies found during initial merge processing to the request that will be processed by the dependency solver.
public onDependencySolve ( Composer\Installer\InstallerEvent $event )
$event Composer\Installer\InstallerEvent

onInit() public method

Handle an event callback for initialization.
public onInit ( Composer\EventDispatcher\Event $event )
$event Composer\EventDispatcher\Event

onInstallUpdateOrDump() public method

Handle an event callback for an install, update or dump command by checking for "merge-plugin" in the "extra" data and merging package contents if found.
public onInstallUpdateOrDump ( Composer\Script\Event $event )
$event Composer\Script\Event

onPostInstallOrUpdate() public method

Handle an event callback following an install or update command. If our plugin was installed during the run then trigger an update command to process any merge-patterns in the current config.
public onPostInstallOrUpdate ( Composer\Script\Event $event )
$event Composer\Script\Event

onPostPackageInstall() public method

Handle an event callback following installation of a new package by checking to see if the package that was installed was our plugin.
public onPostPackageInstall ( Composer\Installer\PackageEvent $event )
$event Composer\Installer\PackageEvent

Property Details

$composer protected_oe property

protected Composer,Composer $composer
return Composer\Composer

$loaded protected_oe property

Files that have already been fully processed
protected string[] $loaded
return string[]

$loadedNoDev protected_oe property

Files that have already been partially processed
protected string[] $loadedNoDev
return string[]

$logger protected_oe property

protected Logger,Wikimedia\Composer $logger
return Wikimedia\Composer\Logger

$state protected_oe property

protected PluginState,Wikimedia\Composer\Merge $state
return Wikimedia\Composer\Merge\PluginState