Skip to content

Commit f505c8d

Browse files
committed
Register callbacks with highest priority
Attempt to take action before other Composer plugins that may be in use by registering our callbacks using a very high priority (50,000) rather than the default priority of 0. Closes #99
1 parent e8aa6a9 commit f505c8d

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/MergePlugin.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ class MergePlugin implements PluginInterface, EventSubscriberInterface
9292
*/
9393
const COMPAT_PLUGINEVENTS_INIT = 'init';
9494

95+
/**
96+
* Priority that plugin uses to register callbacks.
97+
*/
98+
const CALLBACK_PRIORITY = 50000;
99+
95100
/**
96101
* @var Composer $composer
97102
*/
@@ -140,14 +145,22 @@ public static function getSubscribedEvents()
140145
// Use our own constant to make this event optional. Once
141146
// composer-1.1 is required, this can use PluginEvents::INIT
142147
// instead.
143-
self::COMPAT_PLUGINEVENTS_INIT => 'onInit',
144-
InstallerEvents::PRE_DEPENDENCIES_SOLVING => 'onDependencySolve',
145-
PackageEvents::POST_PACKAGE_INSTALL => 'onPostPackageInstall',
146-
ScriptEvents::POST_INSTALL_CMD => 'onPostInstallOrUpdate',
147-
ScriptEvents::POST_UPDATE_CMD => 'onPostInstallOrUpdate',
148-
ScriptEvents::PRE_AUTOLOAD_DUMP => 'onInstallUpdateOrDump',
149-
ScriptEvents::PRE_INSTALL_CMD => 'onInstallUpdateOrDump',
150-
ScriptEvents::PRE_UPDATE_CMD => 'onInstallUpdateOrDump',
148+
self::COMPAT_PLUGINEVENTS_INIT =>
149+
array('onInit', self::CALLBACK_PRIORITY),
150+
InstallerEvents::PRE_DEPENDENCIES_SOLVING =>
151+
array('onDependencySolve', self::CALLBACK_PRIORITY),
152+
PackageEvents::POST_PACKAGE_INSTALL =>
153+
array('onPostPackageInstall', self::CALLBACK_PRIORITY),
154+
ScriptEvents::POST_INSTALL_CMD =>
155+
array('onPostInstallOrUpdate', self::CALLBACK_PRIORITY),
156+
ScriptEvents::POST_UPDATE_CMD =>
157+
array('onPostInstallOrUpdate', self::CALLBACK_PRIORITY),
158+
ScriptEvents::PRE_AUTOLOAD_DUMP =>
159+
array('onInstallUpdateOrDump', self::CALLBACK_PRIORITY),
160+
ScriptEvents::PRE_INSTALL_CMD =>
161+
array('onInstallUpdateOrDump', self::CALLBACK_PRIORITY),
162+
ScriptEvents::PRE_UPDATE_CMD =>
163+
array('onInstallUpdateOrDump', self::CALLBACK_PRIORITY),
151164
);
152165
}
153166

0 commit comments

Comments
 (0)