|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © Vaimo Group. All rights reserved. |
|
4
|
|
|
* See LICENSE_VAIMO.txt for license details. |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace Vaimo\ComposerPatches\Repository\Lock; |
|
7
|
|
|
|
|
8
|
|
|
use Vaimo\ComposerPatches\Composer\ConfigKeys as Config; |
|
9
|
|
|
use Vaimo\ComposerPatches\Config as PluginConfig; |
|
10
|
|
|
use Vaimo\ComposerPatches\Composer\Constraint; |
|
11
|
|
|
|
|
12
|
|
|
class Sanitizer |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var \Vaimo\ComposerPatches\Managers\LockerManager |
|
16
|
|
|
*/ |
|
17
|
|
|
private $lockerManager; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var \Vaimo\ComposerPatches\Utils\DataUtils |
|
21
|
|
|
*/ |
|
22
|
|
|
private $dataUtils; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param \Composer\IO\IOInterface $cliIO |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct( |
|
28
|
|
|
\Composer\IO\IOInterface $cliIO |
|
29
|
|
|
) { |
|
30
|
|
|
$this->lockerManager = new \Vaimo\ComposerPatches\Managers\LockerManager($cliIO); |
|
31
|
|
|
|
|
32
|
|
|
$this->dataUtils = new \Vaimo\ComposerPatches\Utils\DataUtils(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function sanitize() |
|
36
|
|
|
{ |
|
37
|
|
|
if (!$lockData = $this->lockerManager->readLockData()) { |
|
38
|
|
|
return; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$queriedPaths = array( |
|
42
|
|
|
implode('/', array(Config::PACKAGES, Constraint::ANY)), |
|
43
|
|
|
implode('/', array(Config::PACKAGES_DEV, Constraint::ANY)) |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
$nodes = $this->dataUtils->getNodeReferencesByPaths($lockData, $queriedPaths); |
|
47
|
|
|
|
|
48
|
|
|
foreach ($nodes as &$node) { |
|
49
|
|
|
if (!isset($node[Config::CONFIG_ROOT][PluginConfig::APPLIED_FLAG])) { |
|
50
|
|
|
continue; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
unset($node[Config::CONFIG_ROOT][PluginConfig::APPLIED_FLAG]); |
|
54
|
|
|
|
|
55
|
|
|
if ($node[Config::CONFIG_ROOT]) { |
|
56
|
|
|
continue; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
unset($node[Config::CONFIG_ROOT]); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
unset($node); |
|
63
|
|
|
|
|
64
|
|
|
$this->lockerManager->writeLockData($lockData); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|