1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sylius\Bundle\CoreBundle\Command; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
16
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
17
|
|
|
use Symfony\Component\Process\Exception\RuntimeException; |
18
|
|
|
|
19
|
|
|
final class InstallCommand extends AbstractInstallCommand |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
private $commands = [ |
25
|
|
|
[ |
26
|
|
|
'command' => 'check-requirements', |
27
|
|
|
'message' => 'Checking system requirements.', |
28
|
|
|
], |
29
|
|
|
[ |
30
|
|
|
'command' => 'database', |
31
|
|
|
'message' => 'Setting up the database.', |
32
|
|
|
], |
33
|
|
|
[ |
34
|
|
|
'command' => 'setup', |
35
|
|
|
'message' => 'Shop configuration.', |
36
|
|
|
], |
37
|
|
|
[ |
38
|
|
|
'command' => 'assets', |
39
|
|
|
'message' => 'Installing assets.', |
40
|
|
|
], |
41
|
|
|
]; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
|
|
protected function configure() |
47
|
|
|
{ |
48
|
|
|
$this |
49
|
|
|
->setName('sylius:install') |
50
|
|
|
->setDescription('Installs Sylius in your preferred environment.') |
51
|
|
|
->setHelp(<<<EOT |
52
|
|
|
The <info>%command.name%</info> command installs Sylius. |
53
|
|
|
EOT |
54
|
|
|
) |
55
|
|
|
; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
62
|
|
|
{ |
63
|
|
|
$outputStyle = new SymfonyStyle($input, $output); |
64
|
|
|
$outputStyle->writeln('<info>Installing Sylius...</info>'); |
65
|
|
|
$outputStyle->writeln($this->getSyliusLogo()); |
66
|
|
|
|
67
|
|
|
$this->ensureDirectoryExistsAndIsWritable($this->getContainer()->getParameter('kernel.cache_dir'), $output); |
68
|
|
|
|
69
|
|
|
$errored = false; |
70
|
|
|
foreach ($this->commands as $step => $command) { |
71
|
|
|
try { |
72
|
|
|
$outputStyle->newLine(); |
73
|
|
|
$outputStyle->section(sprintf( |
74
|
|
|
'Step %d of %d. <info>%s</info>', |
75
|
|
|
$step + 1, |
76
|
|
|
count($this->commands), |
77
|
|
|
$command['message'] |
78
|
|
|
)); |
79
|
|
|
$this->commandExecutor->runCommand('sylius:install:'.$command['command'], [], $output); |
80
|
|
|
} catch (RuntimeException $exception) { |
81
|
|
|
$errored = true; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
$frontControllerPath = 'prod' === $this->getEnvironment() ? '/' : sprintf('/app_%s.php', $this->getEnvironment()); |
86
|
|
|
|
87
|
|
|
$outputStyle->newLine(2); |
88
|
|
|
$outputStyle->success($this->getProperFinalMessage($errored)); |
89
|
|
|
$outputStyle->writeln(sprintf( |
90
|
|
|
'You can now open your store at the following path under the website root: <info>%s.</info>', |
91
|
|
|
$frontControllerPath |
92
|
|
|
)); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param bool $errored |
97
|
|
|
* |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
|
|
private function getProperFinalMessage($errored) |
101
|
|
|
{ |
102
|
|
|
if ($errored) { |
103
|
|
|
return 'Sylius has been installed, but some error occurred.'; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
return 'Sylius has been successfully installed.'; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
|
|
private function getSyliusLogo() |
113
|
|
|
{ |
114
|
|
|
return ' |
115
|
|
|
<info>,</info> |
116
|
|
|
<info>,;:,</info> |
117
|
|
|
<info>`;;;.:`</info> |
118
|
|
|
<info>`::;` :`</info> |
119
|
|
|
<info>:::` `</info> .\'++: \'\'. \'. |
120
|
|
|
<info>`:::</info> :+\',;+\' :+; `+. |
121
|
|
|
<info>::::</info> +\' :\' `+; |
122
|
|
|
<info>`:::,</info> \'+` ++ :+.`+; `++. ;+\' \'\' ,++++. |
123
|
|
|
<info>,:::`</info> `++\'. .+: `+\' `+; .+, ;+ +\' +; \'\' |
124
|
|
|
<info>::::`</info> ,+++. \'+` :+. `+; `+, ;+ +\' \'+. |
125
|
|
|
<info>,. .::::</info> .++` `+: +\' `+; `+, ;+ +\' `;++; |
126
|
|
|
<info>`;;.:::` :::::</info> :+. \'+,+. `+; `+, ;+ `+\' .++ |
127
|
|
|
<info>.;;;;;;::`.::::,</info> +\'` `++ `++\' `+; `+: :+. `++\' \'. ;+ |
128
|
|
|
<info>,;;;;;;;;;:::::</info> .+++++` ;+, ++; ++, `\'+++,\'+\' :++++, |
129
|
|
|
<info>,;;;;;;;;;:::</info>` ;\' |
130
|
|
|
<info>:;;;;;;;;;:,</info> :.:+, |
131
|
|
|
<info>;;;;;;;;;:</info> ;++,' |
132
|
|
|
; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|