-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathPlugin.php
More file actions
83 lines (74 loc) · 2.21 KB
/
Copy pathPlugin.php
File metadata and controls
83 lines (74 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* @file
* Contains DrupalComposer\DrupalScaffold\Plugin.
*/
namespace DrupalComposer\DrupalScaffold;
use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\Installer\PackageEvents;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\Installer\PackageEvent;
use Composer\Script\ScriptEvents;
/**
* Composer plugin for handling drupal scaffold.
*/
class Plugin implements PluginInterface, EventSubscriberInterface {
/**
* @var \DrupalComposer\DrupalScaffold\Handler
*/
protected $handler;
/**
* {@inheritdoc}
*/
public function activate(Composer $composer, IOInterface $io) {
// We use a separate PluginScripts object. This way we separate
// functionality and also avoid some debug issues with the plugin being
// copied on initialisation.
// @see \Composer\Plugin\PluginManager::registerPackage()
$this->handler = new Handler($composer, $io);
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
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',
);
}
/**
* Post package event behaviour.
*
* @param \Composer\Installer\PackageEvent $event
*/
public function postPackage(PackageEvent $event) {
$this->handler->onPostPackageEvent($event);
}
/**
* Post command event callback.
*
* @param \Composer\Script\Event $event
*/
public function postCmd(\Composer\Script\Event $event) {
$this->handler->onPostCmdEvent($event);
}
/**
* Script callback for putting in composer scripts to download the
* scaffold files.
*
* @param \Composer\Script\Event $event
*/
public static function scaffold(\Composer\Script\Event $event) {
$handler = new Handler($event->getComposer(), $event->getIO());
if ($handler->getDrupalCorePackage()) {
$handler->downloadScaffold();
// Generate the autoload.php file after generating the scaffold files.
$handler->generateAutoload();
}
}
}