1
|
|
|
<?php namespace Arcanedev\Composer\Entities\PackageTraits; |
2
|
|
|
|
3
|
|
|
use Composer\Package\BasePackage; |
4
|
|
|
use Composer\Package\RootPackageInterface; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Trait LinksTrait |
8
|
|
|
* |
9
|
|
|
* @package Arcanedev\Composer\Entities\PackageTraits |
10
|
|
|
* @author ARCANEDEV <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
trait LinksTrait |
13
|
|
|
{ |
14
|
|
|
/* ------------------------------------------------------------------------------------------------ |
15
|
|
|
| Traits |
16
|
|
|
| ------------------------------------------------------------------------------------------------ |
17
|
|
|
*/ |
18
|
|
|
use PackageTrait; |
19
|
|
|
|
20
|
|
|
/* ------------------------------------------------------------------------------------------------ |
21
|
|
|
| Main Functions |
22
|
|
|
| ------------------------------------------------------------------------------------------------ |
23
|
|
|
*/ |
24
|
|
|
/** |
25
|
|
|
* Merge package links of the given type into a RootPackageInterface |
26
|
|
|
* |
27
|
|
|
* @param string $type 'conflict', 'replace' or 'provide' |
28
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
29
|
|
|
*/ |
30
|
|
|
protected function mergePackageLinks($type, RootPackageInterface $root) |
31
|
|
|
{ |
32
|
|
|
$linkType = BasePackage::$supportedLinkTypes[$type]; |
33
|
|
|
$getter = 'get' . ucfirst($linkType['method']); |
34
|
|
|
$setter = 'set' . ucfirst($linkType['method']); |
35
|
|
|
$links = $this->getPackage()->{$getter}(); |
36
|
|
|
|
37
|
|
|
if ( ! empty($links)) { |
38
|
|
|
$unwrapped = static::unwrapIfNeeded($root, $setter); |
39
|
|
|
|
40
|
|
|
// @codeCoverageIgnoreStart |
41
|
|
|
if ($root !== $unwrapped) { |
42
|
|
|
$this->getLogger()->warning( |
43
|
|
|
'This Composer version does not support ' . |
44
|
|
|
"'{$type}' merging for aliased packages." |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
// @codeCoverageIgnoreEnd |
48
|
|
|
|
49
|
|
|
$unwrapped->{$setter}(array_merge( |
50
|
|
|
$root->{$getter}(), |
51
|
|
|
$this->replaceSelfVersionDependencies($type, $links, $root) |
52
|
|
|
)); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Update Links with a 'self.version' constraint with the root package's version. |
58
|
|
|
* |
59
|
|
|
* @param string $type |
60
|
|
|
* @param array $links |
61
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
62
|
|
|
* |
63
|
|
|
* @return array |
64
|
|
|
*/ |
65
|
|
|
abstract protected function replaceSelfVersionDependencies( |
66
|
|
|
$type, array $links, RootPackageInterface $root |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|