1 | <?php |
||
12 | abstract class HoneybadgerInstallCommand extends Command |
||
13 | { |
||
14 | use RequiredInput; |
||
15 | |||
16 | /** |
||
17 | * The name and signature of the console command. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $signature = 'honeybadger:install {apiKey?}'; |
||
22 | |||
23 | /** |
||
24 | * The console command description. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $description = 'Install and configure Honeybadger'; |
||
29 | |||
30 | /** |
||
31 | * Results of each step of the install. |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $results = []; |
||
36 | |||
37 | /** |
||
38 | * Configuration from gathered input. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $config = []; |
||
43 | |||
44 | /** |
||
45 | * Execute the console command. |
||
46 | * |
||
47 | * @return mixed |
||
48 | */ |
||
49 | public function handle() |
||
68 | |||
69 | /** |
||
70 | * Publish the configuration file to the framework. |
||
71 | * |
||
72 | * @return bool |
||
73 | */ |
||
74 | abstract public function publishConfig(); |
||
75 | |||
76 | /** |
||
77 | * Prompt for input and gather responses. |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | private function gatherConfig() |
||
88 | |||
89 | /** |
||
90 | * Prompt for the API key. |
||
91 | * |
||
92 | * @return string |
||
93 | */ |
||
94 | private function promptForApiKey() |
||
98 | |||
99 | /** |
||
100 | * Send test exception to Honeybadger. |
||
101 | * |
||
102 | * @return void |
||
103 | */ |
||
104 | private function sendTest() |
||
113 | |||
114 | /** |
||
115 | * Write configuration values to the env files. |
||
116 | * |
||
117 | * @return void |
||
118 | */ |
||
119 | private function writeEnv() |
||
131 | |||
132 | /** |
||
133 | * Whether the configuration needs to be published or no. |
||
134 | * |
||
135 | * @return bool |
||
136 | */ |
||
137 | private function shouldPublishConfig() |
||
141 | |||
142 | /** |
||
143 | * Write the configurations to dotenv files. |
||
144 | * |
||
145 | * @param array $config |
||
146 | * @param string $file |
||
147 | * @return bool |
||
148 | */ |
||
149 | private function writeConfig($config, $file = '.env') |
||
164 | |||
165 | /** |
||
166 | * Add the results of each installation step. |
||
167 | * |
||
168 | * @param string $name |
||
169 | * @param bool $result |
||
170 | * @return void |
||
171 | */ |
||
172 | public function task($name, $result) |
||
176 | |||
177 | /** |
||
178 | * Output the results of each step of the installation. |
||
179 | * |
||
180 | * @return void |
||
181 | */ |
||
182 | private function outputResults() |
||
191 | } |
||
192 |