1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LCI\MODX\Orchestrator\Console\Command; |
4
|
|
|
|
5
|
|
|
use LCI\MODX\Console\Command\BaseCommand; |
6
|
|
|
use LCI\MODX\Orchestrator\Orchestrator; |
7
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
9
|
|
|
use Symfony\Component\Console\Input\InputOption; |
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
11
|
|
|
|
12
|
|
|
class UninstallPackages extends BaseCommand |
13
|
|
|
{ |
14
|
|
|
public $loadMODX = true; |
15
|
|
|
|
16
|
|
|
protected function configure() |
17
|
|
|
{ |
18
|
|
|
$this |
19
|
|
|
->setName('orchestrator:remove') |
20
|
|
|
->setAliases(['orch-remove']) |
21
|
|
|
->setDescription('Uninstall Package, this will run migrations down for related packages'); |
22
|
|
|
|
23
|
|
|
$this->addArgument( |
24
|
|
|
'package', |
25
|
|
|
InputArgument::REQUIRED, |
26
|
|
|
'Enter a valid package name, like lci/stockpile. Multiple packages can separated by a comma.' |
27
|
|
|
) |
28
|
|
|
->addOption( |
29
|
|
|
'type', |
30
|
|
|
't', |
31
|
|
|
InputOption::VALUE_OPTIONAL, |
32
|
|
|
'Server type passed to run migrations, default is master. Possible master, staging, dev and local', |
33
|
|
|
'master' |
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Runs the command. |
39
|
|
|
* |
40
|
|
|
* @param InputInterface $input |
41
|
|
|
* @param OutputInterface $output |
42
|
|
|
* @return int|null|void |
43
|
|
|
* @throws \LCI\Blend\Exception\MigratorException |
44
|
|
|
*/ |
45
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
46
|
|
|
{ |
47
|
|
|
$packages = explode(',', $input->getArgument('package')); |
|
|
|
|
48
|
|
|
$type = $input->getOption('type'); |
49
|
|
|
|
50
|
|
|
foreach ($packages as $package) { |
51
|
|
|
$output->writeln('### Orchestrator::uninstallComposerPackage() for '.$package.' and type: '.$type.' ###'); |
52
|
|
|
Orchestrator::uninstallComposerPackage($package, $type); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|