|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\Installer\SubCommand; |
|
4
|
|
|
|
|
5
|
|
|
use N98\Magento\Command\SubCommand\AbstractSubCommand; |
|
6
|
|
|
use N98\Util\OperatingSystem; |
|
7
|
|
|
use Symfony\Component\Process\ProcessBuilder; |
|
8
|
|
|
|
|
9
|
|
|
class InstallSampleData extends AbstractSubCommand |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @return bool |
|
|
|
|
|
|
13
|
|
|
*/ |
|
14
|
|
|
public function execute() |
|
15
|
|
|
{ |
|
16
|
|
|
if ($this->input->getOption('noDownload')) { |
|
17
|
|
|
return false; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
$installationFolder = $this->config->getString('installationFolder'); |
|
21
|
|
|
chdir($installationFolder); |
|
22
|
|
|
|
|
23
|
|
|
$dialog = $this->getCommand()->getHelper('dialog'); |
|
24
|
|
|
|
|
25
|
|
|
if ($this->input->getOption('installSampleData') !== null) { |
|
26
|
|
|
$installSampleData = $this->getCommand()->parseBoolOption($this->input->getOption('installSampleData')); |
|
27
|
|
|
} else { |
|
28
|
|
|
$installSampleData = $dialog->askConfirmation( |
|
29
|
|
|
$this->output, |
|
30
|
|
|
'<question>Install sample data?</question> <comment>[y]</comment>: ' |
|
31
|
|
|
); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
if ($installSampleData) { |
|
35
|
|
|
$this->runSampleDataInstaller(); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
protected function runSampleDataInstaller() |
|
40
|
|
|
{ |
|
41
|
|
|
$installationArgs = $this->config->getArray('installation_args'); |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
$processBuilder = new ProcessBuilder([ |
|
44
|
|
|
'php', |
|
45
|
|
|
'bin/magento', |
|
46
|
|
|
'sampledata:deploy', |
|
47
|
|
|
]); |
|
48
|
|
|
|
|
49
|
|
|
if (!OperatingSystem::isWindows()) { |
|
50
|
|
|
$processBuilder->setPrefix('/usr/bin/env'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$process = $processBuilder->getProcess(); |
|
54
|
|
|
$process->setTimeout(86400); |
|
55
|
|
|
$process->start(); |
|
56
|
|
|
$process->wait(function ($type, $buffer) { |
|
57
|
|
|
$this->output->write($buffer, false); |
|
58
|
|
|
}); |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
// @TODO Refactor code duplication |
|
62
|
|
|
if (!OperatingSystem::isWindows()) { |
|
63
|
|
|
$processBuilder->setPrefix('/usr/bin/env'); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
$processBuilder = new ProcessBuilder( |
|
67
|
|
|
array( |
|
68
|
|
|
'php', |
|
69
|
|
|
'bin/magento', |
|
70
|
|
|
'setup:upgrade' |
|
71
|
|
|
) |
|
72
|
|
|
); |
|
73
|
|
|
$process = $processBuilder->getProcess(); |
|
74
|
|
|
$process->setTimeout(86400); |
|
75
|
|
|
$process->start(); |
|
76
|
|
|
$process->wait(function ($type, $buffer) { |
|
77
|
|
|
$this->output->write($buffer, false); |
|
78
|
|
|
}); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.