Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / drupal-composer / drupal-scaffold / src / Plugin.php
index 73fd2a0fcc22b98848c12b58cde6f917b4baf408..7833903f59449ea2c1290f5f3bdf613e63b6296b 100644 (file)
@@ -1,23 +1,23 @@
 <?php
-/**
- * @file
- * Contains DrupalComposer\DrupalScaffold\Plugin.
- */
 
 namespace DrupalComposer\DrupalScaffold;
 
+use Composer\Script\Event;
+use Composer\Plugin\CommandEvent;
 use Composer\Composer;
 use Composer\EventDispatcher\EventSubscriberInterface;
 use Composer\Installer\PackageEvent;
 use Composer\Installer\PackageEvents;
 use Composer\IO\IOInterface;
+use Composer\Plugin\Capable;
+use Composer\Plugin\PluginEvents;
 use Composer\Plugin\PluginInterface;
 use Composer\Script\ScriptEvents;
 
 /**
  * Composer plugin for handling drupal scaffold.
  */
-class Plugin implements PluginInterface, EventSubscriberInterface {
+class Plugin implements PluginInterface, EventSubscriberInterface, Capable {
 
   /**
    * @var \DrupalComposer\DrupalScaffold\Handler
@@ -35,6 +35,15 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
     $this->handler = new Handler($composer, $io);
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getCapabilities() {
+    return array(
+      'Composer\Plugin\Capability\CommandProvider' => 'DrupalComposer\DrupalScaffold\CommandProvider',
+    );
+  }
+
   /**
    * {@inheritdoc}
    */
@@ -42,12 +51,20 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
     return array(
       PackageEvents::POST_PACKAGE_INSTALL => 'postPackage',
       PackageEvents::POST_PACKAGE_UPDATE => 'postPackage',
-      //PackageEvents::POST_PACKAGE_UNINSTALL => 'postPackage',
-      //ScriptEvents::POST_INSTALL_CMD => 'postCmd',
       ScriptEvents::POST_UPDATE_CMD => 'postCmd',
+      PluginEvents::COMMAND => 'cmdBegins',
     );
   }
 
+  /**
+   * Command begins event callback.
+   *
+   * @param \Composer\Plugin\CommandEvent $event
+   */
+  public function cmdBegins(CommandEvent $event) {
+    $this->handler->onCmdBeginsEvent($event);
+  }
+
   /**
    * Post package event behaviour.
    *
@@ -62,7 +79,7 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
    *
    * @param \Composer\Script\Event $event
    */
-  public function postCmd(\Composer\Script\Event $event) {
+  public function postCmd(Event $event) {
     $this->handler->onPostCmdEvent($event);
   }
 
@@ -71,11 +88,16 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
    * scaffold files.
    *
    * @param \Composer\Script\Event $event
+   *
+   * @deprecated since version 2.5.0, to be removed in 3.0. Use the command
+   *   "composer drupal:scaffold" instead.
    */
-  public static function scaffold(\Composer\Script\Event $event) {
+  public static function scaffold(Event $event) {
+    @trigger_error('\DrupalComposer\DrupalScaffold\Plugin::scaffold is deprecated since version 2.5.0 and will be removed in 3.0. Use "composer drupal:scaffold" instead.', E_USER_DEPRECATED);
     $handler = new Handler($event->getComposer(), $event->getIO());
     $handler->downloadScaffold();
     // Generate the autoload.php file after generating the scaffold files.
     $handler->generateAutoload();
   }
+
 }