This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Plugin.php
65 lines (58 loc) · 1.61 KB
/
Plugin.php
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
<?php
declare(strict_types=1);
namespace Rinvex\Composer\Models;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
class Plugin implements PluginInterface
{
/**
* The composer installer instances.
*
* @var \Rinvex\Composer\Models\Installer[]
*/
protected $installers;
/**
* Apply plugin modifications to Composer.
*
* @param Composer $composer
* @param IOInterface $io
*
* @throws \Exception
*/
public function activate(Composer $composer, IOInterface $io)
{
foreach (Config::getKeys() as $type) {
$this->installers[] = ($installer = new Installer($io, $composer, $type));
$composer->getInstallationManager()->addInstaller($installer);
}
}
/**
* Remove any hooks from Composer.
*
* This will be called when a plugin is deactivated before being
* uninstalled, but also before it gets upgraded to a new version
* so the old one can be deactivated and the new one activated.
*
* @param Composer $composer
* @param IOInterface $io
*/
public function deactivate(Composer $composer, IOInterface $io)
{
foreach ($this->installers as $installer) {
$composer->getInstallationManager()->removeInstaller($installer);
}
}
/**
* Prepare the plugin to be uninstalled.
*
* This will be called after deactivate.
*
* @param Composer $composer
* @param IOInterface $io
*/
public function uninstall(Composer $composer, IOInterface $io)
{
//
}
}