Composer\Installer\InstallerEvent * - Composer\Installer\PackageEvents::* -> Composer\Installer\PackageEvent * - Composer\Installer\PluginEvents::INIT -> Composer\EventDispatcher\Event * - Composer\Installer\PluginEvents::COMMAND -> Composer\Plugin\CommandEvent * - Composer\Installer\PluginEvents::PRE_FILE_DOWNLOAD * -> Composer\Plugin\PreFileDownloadEvent * - Composer\Script\ScriptEvents::* -> Composer\Script\Event */ public static function getSubscribedEvents() { return [ ScriptEvents::POST_INSTALL_CMD => 'onScriptEvent', ScriptEvents::POST_UPDATE_CMD => 'onScriptEvent', ]; } /** * Apply plugin modifications to Composer. * * @param \Composer\Composer $composer * The currently running Composer instance. * @param \Composer\IO\IOInterface $io * The Composer I/O. */ public function activate(Composer $composer, IOInterface $io) { $this->composer = $composer; $this->io = $io; } /** * Composer plugin API: describe the plugin capabilities. */ public function getCapabilities() { return [ CommandProvider::class => BuilderCommandProvider::class, ]; } protected function showCommands() { $capabilities = $this->getCapabilities(); if (empty($capabilities[CommandProvider::class])) { return; } $providerClass = $capabilities[CommandProvider::class]; /** @var \Composer\Plugin\Capability\CommandProvider $provider */ $provider = new $providerClass([ 'composer' => $this->composer, 'io' => $io = $this->io, 'plugin' => NULL, ]); $commands = $provider->getCommands(); $io->write("Available build commands:"); foreach ($commands as $command) { $io->write("- " . $command->getName()); } } /** * Event callback: run build:settings on post-install|update only. * * @param \Composer\Script\Event $event * The subscribed event triggering this callback. * * @throws \Exception */ public function onScriptEvent(ScriptEvent $event) { if (in_array($event->getName(), [ ScriptEvents::POST_INSTALL_CMD, ScriptEvents::POST_UPDATE_CMD, ])) { // FIXME without an argument, the command should build all templates. // $buildCommand = new BuildSettingsCommand($event->getName()); // $buildCommand->run(new ArgvInput([]), new ConsoleOutput()); // Verbosity seems limited to 32, while the test expects 64 or 128. if ($event->getIO()->isVerbose()) { $this->showCommands(); } } } }