1 | <?php namespace Lanin\Laravel\SetupWizard\Commands\Steps; |
||
5 | class DotEnv extends AbstractStep |
||
6 | { |
||
7 | const RANDOM = 'random'; |
||
8 | const SELECT = 'select'; |
||
9 | const INPUT = 'input'; |
||
10 | |||
11 | /** |
||
12 | * Array of bootstrappers to reload Application config. |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $boostrappers = [ |
||
17 | 'Lanin\Laravel\SetupWizard\Support\Bootstrap\DetectEnvironment', |
||
18 | 'Lanin\Laravel\SetupWizard\Support\Bootstrap\LoadConfiguration', |
||
19 | 'Illuminate\Foundation\Bootstrap\ConfigureLogging', |
||
20 | ]; |
||
21 | |||
22 | /** |
||
23 | * Return short command description. |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | 4 | public function prompt() |
|
31 | |||
32 | /** |
||
33 | * Check if .env file exist |
||
34 | * |
||
35 | * @return bool |
||
36 | */ |
||
37 | 4 | protected function envFileExist() |
|
41 | |||
42 | /** |
||
43 | * Return path where to search .env files. |
||
44 | * |
||
45 | * @param string $file |
||
46 | * @return string |
||
47 | */ |
||
48 | 6 | protected function envFilePath($file = '.env') |
|
52 | |||
53 | /** |
||
54 | * Proceed step. |
||
55 | * |
||
56 | * @return array |
||
57 | */ |
||
58 | 2 | public function prepare() |
|
75 | |||
76 | /** |
||
77 | * Get variable options from configs. |
||
78 | * |
||
79 | * @param string $name |
||
80 | * @return array |
||
81 | */ |
||
82 | 2 | protected function getVariableOptions($name) |
|
91 | |||
92 | /** |
||
93 | * Chooses what env file to use. |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | 2 | protected function envFileToUseForDefaults() |
|
110 | |||
111 | /** |
||
112 | * Run input prompt. |
||
113 | * |
||
114 | * @param string $name |
||
115 | * @param array $options |
||
116 | * @param string|null $default |
||
117 | * @return string |
||
118 | */ |
||
119 | 4 | protected function runInput($name, array $options, $default = null) |
|
123 | |||
124 | /** |
||
125 | * Run select prompt. |
||
126 | * |
||
127 | * @param string $name |
||
128 | * @param array $options |
||
129 | * @param string|null $default |
||
130 | * @return string |
||
131 | */ |
||
132 | 4 | protected function runSelect($name, array $options, $default = null) |
|
140 | |||
141 | /** |
||
142 | * Run random prompt. |
||
143 | * |
||
144 | * @param string $name |
||
145 | * @param array $options |
||
146 | * @param string $default |
||
147 | * @return string |
||
148 | */ |
||
149 | 6 | protected function runRandom($name, array $options, $default = 'SomeRandomString') |
|
160 | |||
161 | /** |
||
162 | * Generate a random key for the application. |
||
163 | * |
||
164 | * @param string $cipher |
||
165 | * @return string |
||
166 | */ |
||
167 | 4 | protected function getRandomKey($cipher) |
|
176 | |||
177 | /** |
||
178 | * Preview results. |
||
179 | * |
||
180 | * @param mixed $results |
||
181 | * @return void |
||
182 | */ |
||
183 | 2 | public function preview($results) |
|
187 | |||
188 | /** |
||
189 | * Generate prompt text. |
||
190 | * |
||
191 | * @param string $name |
||
192 | * @param string $prompt |
||
193 | * @return string |
||
194 | */ |
||
195 | 12 | protected function generatePrompt($name, $prompt) |
|
199 | |||
200 | /** |
||
201 | * Finish step. |
||
202 | * |
||
203 | * @param mixed $results |
||
204 | * @return bool |
||
205 | */ |
||
206 | 4 | public function finish($results) |
|
236 | |||
237 | /** |
||
238 | * Save .env file. |
||
239 | * |
||
240 | * @param $results |
||
241 | * @return bool |
||
242 | */ |
||
243 | 2 | protected function saveFile($results) |
|
253 | } |
||
254 |