|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of tenside/core. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Christian Schiffler <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* This project is provided in good faith and hope to be usable by anyone. |
|
12
|
|
|
* |
|
13
|
|
|
* @package tenside/core |
|
14
|
|
|
* @author Christian Schiffler <[email protected]> |
|
15
|
|
|
* @copyright 2015 Christian Schiffler <[email protected]> |
|
16
|
|
|
* @license https://github.com/tenside/core/blob/master/LICENSE MIT |
|
17
|
|
|
* @link https://github.com/tenside/core |
|
18
|
|
|
* @filesource |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace Tenside\Core\Task\Composer; |
|
22
|
|
|
|
|
23
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* This task provides the basic framework for building tasks that perform composer commands. |
|
27
|
|
|
*/ |
|
28
|
|
|
abstract class AbstractPackageManipulatingTask extends AbstractComposerCommandTask |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* The package to install. |
|
32
|
|
|
*/ |
|
33
|
|
|
const SETTING_PACKAGE = 'package'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* The home path of tenside. |
|
37
|
|
|
*/ |
|
38
|
|
|
const SETTING_HOME = 'home'; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* The no update flag. |
|
42
|
|
|
*/ |
|
43
|
|
|
const SETTING_NO_UPDATE = 'no-update'; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Retrieve the names of the packages to manipulate. |
|
47
|
|
|
* |
|
48
|
|
|
* @return array |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getPackage() |
|
51
|
|
|
{ |
|
52
|
|
|
return (array) $this->file->get(self::SETTING_PACKAGE); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Retrieve the home path of tenside. |
|
57
|
|
|
* |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getHome() |
|
61
|
|
|
{ |
|
62
|
|
|
return (string) $this->file->get(self::SETTING_HOME); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Check if the update shall be omitted and only the composer.json shall be manipulated. |
|
67
|
|
|
* |
|
68
|
|
|
* @return bool |
|
69
|
|
|
*/ |
|
70
|
|
|
public function isNoUpdate() |
|
71
|
|
|
{ |
|
72
|
|
|
return (bool) $this->file->has(self::SETTING_NO_UPDATE); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* {@inheritDoc} |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function prepareInput() |
|
79
|
|
|
{ |
|
80
|
|
|
$arguments = ['packages' => $this->getPackage()]; |
|
81
|
|
|
if ($this->isNoUpdate()) { |
|
82
|
|
|
$arguments['no-update'] = ''; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
$input = new ArrayInput($arguments); |
|
86
|
|
|
$input->setInteractive(false); |
|
87
|
|
|
|
|
88
|
|
|
return $input; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|