Total Complexity | 5 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | final class ComposerEventHandler implements PluginInterface, EventSubscriberInterface |
||
15 | { |
||
16 | private Composer $composer; |
||
17 | private IOInterface $io; |
||
18 | |||
19 | /** |
||
20 | * Returns list of events the plugin is subscribed to. |
||
21 | * |
||
22 | * @return array list of events |
||
23 | */ |
||
24 | public static function getSubscribedEvents(): array |
||
25 | { |
||
26 | return [ |
||
27 | ScriptEvents::POST_AUTOLOAD_DUMP => [ |
||
28 | ['onPostAutoloadDump', 0], |
||
29 | ], |
||
30 | ]; |
||
31 | } |
||
32 | |||
33 | public function activate(Composer $composer, IOInterface $io): void |
||
34 | { |
||
35 | $this->composer = $composer; |
||
36 | $this->io = $io; |
||
37 | } |
||
38 | |||
39 | public function onPostAutoloadDump(Event $event): void |
||
40 | { |
||
41 | require_once $event->getComposer()->getConfig()->get('vendor-dir') . '/autoload.php'; |
||
42 | |||
43 | $plugin = new Plugin($this->composer, $this->io); |
||
44 | $plugin->build(); |
||
45 | } |
||
46 | |||
47 | public function deactivate(Composer $composer, IOInterface $io): void |
||
48 | { |
||
49 | // do nothing |
||
50 | } |
||
51 | |||
52 | public function uninstall(Composer $composer, IOInterface $io): void |
||
54 | // do nothing |
||
55 | } |
||
56 | } |
||
57 |