1 | <?php |
||
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() |
||
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) |
||
108 | |||
109 | /** |
||
110 | * @return string |
||
111 | */ |
||
112 | private function getSyliusLogo() |
||
134 | } |
||
135 |