|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Rinvex\Composer\Installers; |
|
6
|
|
|
|
|
7
|
|
|
use Composer\Package\PackageInterface; |
|
8
|
|
|
use Composer\Repository\InstalledRepositoryInterface; |
|
9
|
|
|
use Composer\Installer\LibraryInstaller as BaseLibraryInstaller; |
|
10
|
|
|
|
|
11
|
|
|
class LibraryInstaller extends BaseLibraryInstaller |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Paths array. |
|
15
|
|
|
* |
|
16
|
|
|
* @var array |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $paths = [ |
|
19
|
|
|
'base' => '/../../../../../', |
|
20
|
|
|
'app' => '/../../../../../app/', |
|
21
|
|
|
'bootstrap' => '/../../../../../bootstrap/', |
|
22
|
|
|
]; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Return the path. |
|
26
|
|
|
* |
|
27
|
|
|
* @param string $path |
|
28
|
|
|
* |
|
29
|
|
|
* @return string |
|
30
|
|
|
*/ |
|
31
|
|
|
protected function getPath($path): string |
|
32
|
|
|
{ |
|
33
|
|
|
$pathsFile = __DIR__.'/../../../../../config/rinvex.composer.php'; |
|
34
|
|
|
$paths = file_exists($pathsFile) ? require $pathsFile : []; |
|
35
|
|
|
|
|
36
|
|
|
return $paths[$path] ?? __DIR__.$this->paths[$path]; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* {@inheritdoc} |
|
41
|
|
|
*/ |
|
42
|
|
|
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
return parent::isInstalled($repo, $package); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Installs specific package. |
|
49
|
|
|
* |
|
50
|
|
|
* @param InstalledRepositoryInterface $repo repository in which to check |
|
51
|
|
|
* @param PackageInterface $package package instance |
|
52
|
|
|
* |
|
53
|
|
|
* @throws \Exception |
|
54
|
|
|
* |
|
55
|
|
|
* @return void |
|
56
|
|
|
*/ |
|
57
|
|
|
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) |
|
58
|
|
|
{ |
|
59
|
|
|
parent::install($repo, $package); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Updates specific package. |
|
64
|
|
|
* |
|
65
|
|
|
* @param InstalledRepositoryInterface $repo repository in which to check |
|
66
|
|
|
* @param PackageInterface $initial already installed package version |
|
67
|
|
|
* @param PackageInterface $target updated version |
|
68
|
|
|
* |
|
69
|
|
|
* @throws InvalidArgumentException if $initial package is not installed |
|
70
|
|
|
* |
|
71
|
|
|
* @return void |
|
72
|
|
|
*/ |
|
73
|
|
|
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) |
|
74
|
|
|
{ |
|
75
|
|
|
parent::update($repo, $initial, $target); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Uninstalls specific package. |
|
80
|
|
|
* |
|
81
|
|
|
* @param InstalledRepositoryInterface $repo repository in which to check |
|
82
|
|
|
* @param PackageInterface $package package instance |
|
83
|
|
|
* |
|
84
|
|
|
* @throws \Exception |
|
85
|
|
|
* |
|
86
|
|
|
* @return void |
|
87
|
|
|
*/ |
|
88
|
|
|
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) |
|
89
|
|
|
{ |
|
90
|
|
|
parent::uninstall($repo, $package); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.