|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the "Composer Shared Package Plugin" package. |
|
5
|
|
|
* |
|
6
|
|
|
* https://github.com/Letudiant/composer-shared-package-plugin |
|
7
|
|
|
* |
|
8
|
|
|
* For the full license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace LEtudiant\Composer; |
|
13
|
|
|
|
|
14
|
|
|
use Composer\Composer; |
|
15
|
|
|
use Composer\Installer\LibraryInstaller; |
|
16
|
|
|
use Composer\IO\IOInterface; |
|
17
|
|
|
use Composer\Plugin\PluginInterface; |
|
18
|
|
|
use LEtudiant\Composer\Data\Package\SharedPackageDataManager; |
|
19
|
|
|
use LEtudiant\Composer\Installer\Config\SharedPackageInstallerConfig; |
|
20
|
|
|
use LEtudiant\Composer\Installer\Solver\SharedPackageSolver; |
|
21
|
|
|
use LEtudiant\Composer\Installer\SharedPackageInstaller; |
|
22
|
|
|
use LEtudiant\Composer\Installer\Solver\SharedPackageInstallerSolver; |
|
23
|
|
|
use LEtudiant\Composer\Util\SymlinkFilesystem; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @author Sylvain Lorinet <[email protected]> |
|
27
|
|
|
*/ |
|
28
|
|
|
class SharedPackagePlugin implements PluginInterface |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @param Composer $composer |
|
32
|
|
|
* @param IOInterface $io |
|
33
|
|
|
*/ |
|
34
|
|
|
public function activate(Composer $composer, IOInterface $io) |
|
35
|
|
|
{ |
|
36
|
|
|
$config = $this->setConfig($composer); |
|
37
|
|
|
|
|
38
|
|
|
$composer->getInstallationManager()->addInstaller(new SharedPackageInstallerSolver( |
|
39
|
|
|
new SharedPackageSolver($config), |
|
40
|
|
|
new SharedPackageInstaller( |
|
41
|
|
|
$io, |
|
42
|
|
|
$composer, |
|
43
|
|
|
new SymlinkFilesystem(), |
|
44
|
|
|
new SharedPackageDataManager($composer), |
|
45
|
|
|
$config |
|
46
|
|
|
), |
|
47
|
|
|
new LibraryInstaller($io, $composer) |
|
48
|
|
|
)); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param Composer $composer |
|
53
|
|
|
* |
|
54
|
|
|
* @return SharedPackageInstallerConfig |
|
55
|
|
|
*/ |
|
56
|
|
|
protected function setConfig(Composer $composer) |
|
57
|
|
|
{ |
|
58
|
|
|
return new SharedPackageInstallerConfig( |
|
59
|
|
|
$composer->getConfig()->get('vendor-dir'), |
|
60
|
|
|
$composer->getConfig()->get('vendor-dir', 1), |
|
61
|
|
|
$composer->getPackage()->getExtra() |
|
62
|
|
|
); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|