Passed
Push — master ( d56c43...736831 )
by Josh
04:39
created

DeployCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 9.9332
1
<?php
2
3
namespace LCI\MODX\Orchestrator\Console\Command;
4
5
use LCI\MODX\Console\Command\BaseCommand;
6
use LCI\MODX\Orchestrator\Deploy\Deploy;
7
use LCI\MODX\Orchestrator\Orchestrator;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class DeployCommand extends BaseCommand
14
{
15
    public $loadMODX = true;
16
17
    protected function configure()
18
    {
19
        $this
20
            ->setName('orchestrator:deploy')
21
            ->setAliases(['deploy'])
22
            ->setDescription('Run deploy script');
23
24
        // show the class used:
25
        $this
26
            ->addOption(
27
            'describe',
28
            'd',
29
            InputOption::VALUE_OPTIONAL,
30
            'Describe the deploy class used and the description of what it will do. 1/0',
31
            0
32
            );
33
        // @TODO list all packages in config
34
    }
35
36
    /**
37
     * Runs the command.
38
     *
39
     * @param InputInterface $input
40
     * @param OutputInterface $output
41
     * @return int|null|void
42
     * @throws \LCI\Blend\Exception\MigratorException
43
     */
44
    protected function execute(InputInterface $input, OutputInterface $output)
45
    {
46
        $describe = (bool)$input->getOption('describe');
47
48
        $modx = $this->console->loadMODX();
49
50
        if (!empty($custom_class = getenv('LCI_MODX_ORCHESTRATOR_DEPLOY_EXTENDED_CLASS'))) {
51
            /** @var Deploy $orchestratorDeploy */
52
            $orchestratorDeploy = new $custom_class($modx);
53
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
54
        } else {
55
            /** @var Deploy $orchestratorDeploy */
56
            $orchestratorDeploy = new Deploy($this);
57
        }
58
59
        if ($describe) {
60
            $output->writeln('Class: '. get_class($orchestratorDeploy));
61
            $orchestratorDeploy->describe($output);
62
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
63
        } else {
64
            $orchestratorDeploy->run($input, $output);
65
        }
66
67
        $output->writeln($this->getRunStats());
68
    }
69
}
70