|
@@ -3,74 +3,86 @@
|
|
|
namespace Fgm\Drupal\Composer;
|
|
|
|
|
|
use Composer\Composer;
|
|
|
-use Composer\EventDispatcher\Event;
|
|
|
use Composer\EventDispatcher\EventSubscriberInterface;
|
|
|
-use Composer\Installer\InstallerEvents;
|
|
|
-use Composer\Installer\PackageEvent;
|
|
|
-use Composer\Installer\PackageEvents;
|
|
|
use Composer\IO\IOInterface;
|
|
|
use Composer\Plugin\Capability\Capability;
|
|
|
use Composer\Plugin\Capability\CommandProvider;
|
|
|
use Composer\Plugin\Capable;
|
|
|
-use Composer\Plugin\CommandEvent;
|
|
|
-use Composer\Plugin\PluginEvents;
|
|
|
use Composer\Plugin\PluginInterface;
|
|
|
use Composer\Script\Event as ScriptEvent;
|
|
|
use Composer\Script\ScriptEvents;
|
|
|
use Symfony\Component\Console\Input\ArgvInput;
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
|
|
|
|
-class Builder implements Capable, Capability, EventSubscriberInterface, PluginInterface {
|
|
|
+class Builder implements Capable, Capability, EventSubscriberInterface, PluginInterface
|
|
|
+{
|
|
|
|
|
|
- /**
|
|
|
- * @var \Composer\Composer
|
|
|
- */
|
|
|
- protected $composer;
|
|
|
+ const NAME = "composer_builder";
|
|
|
|
|
|
- /**
|
|
|
- * @var \Composer\IO\IOInterface
|
|
|
- */
|
|
|
- protected $io;
|
|
|
+ /**
|
|
|
+ * @var \Composer\Composer
|
|
|
+ */
|
|
|
+ protected $composer;
|
|
|
|
|
|
- /**
|
|
|
- * Apply plugin modifications to Composer
|
|
|
- *
|
|
|
- * @param Composer $composer
|
|
|
- * @param IOInterface $io
|
|
|
- */
|
|
|
- public function activate(Composer $composer, IOInterface $io) {
|
|
|
- $this->composer = $composer;
|
|
|
- $this->io = $io;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * @var \Composer\IO\IOInterface
|
|
|
+ */
|
|
|
+ protected $io;
|
|
|
|
|
|
- public function getCapabilities() {
|
|
|
- return [
|
|
|
- CommandProvider::class => BuilderCommandProvider::class,
|
|
|
- ];
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * {@inheritdoc}
|
|
|
+ *
|
|
|
+ * Available events:
|
|
|
+ *
|
|
|
+ * - Composer\Installer\InstallerEvents::* ->
|
|
|
+ * 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',
|
|
|
+ ];
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * {@inheritdoc}
|
|
|
- *
|
|
|
- * Available events:
|
|
|
- *
|
|
|
- * - Composer\Installer\InstallerEvents::* -> 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
|
|
|
+ * @param IOInterface $io
|
|
|
+ */
|
|
|
+ public function activate(Composer $composer, IOInterface $io)
|
|
|
+ {
|
|
|
+ $this->composer = $composer;
|
|
|
+ $this->io = $io;
|
|
|
+ }
|
|
|
|
|
|
- public function onScriptEvent(ScriptEvent $event) {
|
|
|
- $buildCommand = new BuildSettingsCommand($event->getName());
|
|
|
- $buildCommand->run(new ArgvInput([]), new ConsoleOutput());
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * {@inheritDoc}
|
|
|
+ */
|
|
|
+ public function getCapabilities()
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ CommandProvider::class => BuilderCommandProvider::class,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Event callback.
|
|
|
+ *
|
|
|
+ * @param \Composer\Script\Event $event
|
|
|
+ *
|
|
|
+ * @throws \Exception
|
|
|
+ */
|
|
|
+ public function onScriptEvent(ScriptEvent $event)
|
|
|
+ {
|
|
|
+ $buildCommand = new BuildSettingsCommand($event->getName());
|
|
|
+ $buildCommand->run(new ArgvInput([]), new ConsoleOutput());
|
|
|
+ }
|
|
|
}
|