1
|
|
|
<?php namespace Arcanedev\Composer\Entities\PackageTraits; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Composer\Entities\PluginState; |
4
|
|
|
use Arcanedev\Composer\Utilities\Util; |
5
|
|
|
use Composer\Package\RootPackageInterface; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Trait DevTrait |
9
|
|
|
* |
10
|
|
|
* @package Arcanedev\Composer\Entities\PackageTraits |
11
|
|
|
* @author ARCANEDEV <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
trait DevTrait |
14
|
|
|
{ |
15
|
|
|
/* ------------------------------------------------------------------------------------------------ |
16
|
|
|
| Traits |
17
|
|
|
| ------------------------------------------------------------------------------------------------ |
18
|
|
|
*/ |
19
|
|
|
use PackageTrait; |
20
|
|
|
|
21
|
|
|
/* ------------------------------------------------------------------------------------------------ |
22
|
|
|
| Main Functions |
23
|
|
|
| ------------------------------------------------------------------------------------------------ |
24
|
|
|
*/ |
25
|
|
|
/** |
26
|
|
|
* Merge just the dev portion into a RootPackageInterface. |
27
|
|
|
* |
28
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
29
|
|
|
* @param \Arcanedev\Composer\Entities\PluginState $state |
30
|
|
|
*/ |
31
|
99 |
|
public function mergeDevInto(RootPackageInterface $root, PluginState $state) |
32
|
|
|
{ |
33
|
99 |
|
$this->mergeDevRequires($root, $state); |
34
|
99 |
|
$this->mergeDevAutoload($root); |
35
|
99 |
|
$this->mergeReferences($root); |
36
|
99 |
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Merge require-dev into RootPackage. |
40
|
|
|
* |
41
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
42
|
|
|
* @param \Arcanedev\Composer\Entities\PluginState $state |
43
|
|
|
*/ |
44
|
|
|
abstract protected function mergeDevRequires(RootPackageInterface $root, PluginState $state); |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Merge autoload-dev into a RootPackage. |
48
|
|
|
* |
49
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
50
|
|
|
*/ |
51
|
99 |
|
private function mergeDevAutoload(RootPackageInterface $root) |
52
|
|
|
{ |
53
|
99 |
|
if ( ! empty($autoload = $this->getPackage()->getDevAutoload())) { |
54
|
9 |
|
static::unwrapIfNeeded($root, 'setDevAutoload') |
55
|
9 |
|
->setDevAutoload(array_merge_recursive( |
56
|
9 |
|
$root->getDevAutoload(), Util::fixRelativePaths($this->getPath(), $autoload) |
57
|
|
|
)); |
58
|
|
|
} |
59
|
99 |
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Update the root packages reference information. |
63
|
|
|
* |
64
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
65
|
|
|
*/ |
66
|
|
|
abstract protected function mergeReferences(RootPackageInterface $root); |
67
|
|
|
} |
68
|
|
|
|