Completed
Branch develop (e3b860)
by Luke
13:48
created

InstallCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 9
nc 1
nop 5
1
<?php
2
3
/**
4
 * Moodle component manager.
5
 *
6
 * @author Luke Carrier <[email protected]>
7
 * @copyright 2016 Luke Carrier
8
 * @license GPL-3.0+
9
 */
10
11
namespace ComponentManager\Command;
12
13
use ComponentManager\Moodle;
14
use ComponentManager\PackageFormat\PackageFormatFactory;
15
use ComponentManager\PackageRepository\PackageRepositoryFactory;
16
use ComponentManager\PackageSource\PackageSourceFactory;
17
use ComponentManager\PlatformUtil;
18
use ComponentManager\Task\InstallTask;
19
use Psr\Log\LoggerInterface;
20
use Symfony\Component\Console\Input\InputInterface;
21
use Symfony\Component\Console\Output\OutputInterface;
22
use Symfony\Component\Filesystem\Filesystem;
23
24
/**
25
 * Install command.
26
 *
27
 * Installs a component into the Moodle installation in the present working
28
 * directory.
29
 */
30
class InstallCommand extends ProjectAwareCommand {
31
    /**
32
     * Help text.
33
     *
34
     * @var string
35
     */
36
    const HELP = <<<HELP
37
Installs, into the Moodle installation in the present working directory, all of the components listed in its componentmgr.json file.
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 132 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
38
HELP;
39
40
    /**
41
     * Filesystem.
42
     *
43
     * @var \Symfony\Component\Filesystem\Filesystem
44
     */
45
    protected $filesystem;
46
47
    /**
48
     * Initialiser.
49
     *
50
     * @param \Symfony\Component\Filesystem\Filesystem $filesystem
51
     */
52
    public function __construct(PackageRepositoryFactory $packageRepositoryFactory,
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 83 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
53
                                PackageSourceFactory $packageSourceFactory,
54
                                PackageFormatFactory $packageFormatFactory,
55
                                Filesystem $filesystem,
56
                                LoggerInterface $logger) {
57
        $this->filesystem = $filesystem;
58
59
        parent::__construct(
60
                $packageRepositoryFactory, $packageSourceFactory,
61
                $packageFormatFactory, $logger);
62
    }
63
64
    /**
65
     * @override \Symfony\Component\Console\Command\Command
66
     */
67
    protected function configure() {
68
        $this
69
            ->setName('install')
70
            ->setDescription('Installs all packages from componentmgr.json')
71
            ->setHelp(static::HELP);
72
    }
73
74
    /**
75
     * @override \Symfony\Component\Console\Command\Command
76
     */
77
    protected function execute(InputInterface $input, OutputInterface $output) {
78
        $project = $this->getProject();
79
        $moodle  = new Moodle(PlatformUtil::workingDirectory());
80
81
        $task = new InstallTask($project, $this->filesystem, $moodle);
82
        $task->execute($this->logger);
83
    }
84
}
85