1 | <?php namespace Arcanedev\Composer\Entities\PackageTraits; |
||
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 | 99 | protected function mergePackageLinks($type, RootPackageInterface $root) |
|
31 | { |
||
32 | 99 | $linkType = BasePackage::$supportedLinkTypes[$type]; |
|
33 | 99 | $getter = 'get' . ucfirst($linkType['method']); |
|
34 | 99 | $setter = 'set' . ucfirst($linkType['method']); |
|
35 | 99 | $links = $this->getPackage()->{$getter}(); |
|
36 | |||
37 | 99 | if ( ! empty($links)) { |
|
38 | 18 | $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 | 18 | $unwrapped->{$setter}(array_merge( |
|
50 | 18 | $root->{$getter}(), |
|
51 | 18 | $this->replaceSelfVersionDependencies($type, $links, $root) |
|
52 | )); |
||
53 | } |
||
54 | 99 | } |
|
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( |
||
68 | } |
||
69 |