<?php

/**
 * @file
 * Contains LakeDrops\ComposerDevEnvironment\Plugin.
 */

namespace LakeDrops\ComposerDevEnvironment;

use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\Script\ScriptEvents;

/**
 * Composer plugin for handling drupal scaffold.
 */
class Plugin implements PluginInterface, EventSubscriberInterface {

  /**
   * @var \LakeDrops\ComposerDevEnvironment\Handler
   */
  protected $handler;

  /**
   * {@inheritdoc}
   */
  public function activate(Composer $composer, IOInterface $io) {
    $this->handler = new Handler($composer, $io);
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return array(
      ScriptEvents::PRE_UPDATE_CMD => 'test',
    );
  }

  /**
   * Post create project event callback.
   *
   * @param \Composer\Script\Event $event
   */
  public function test($event) {
    $this->handler->test($event);
  }

}