1 | <?php |
||
2 | /** |
||
3 | * Controller.php |
||
4 | * Copyright (c) 2020 [email protected]. |
||
5 | * |
||
6 | * This file is part of the Firefly III bunq importer |
||
7 | * (https://github.com/firefly-iii/bunq-importer). |
||
8 | * |
||
9 | * This program is free software: you can redistribute it and/or modify |
||
10 | * it under the terms of the GNU Affero General Public License as |
||
11 | * published by the Free Software Foundation, either version 3 of the |
||
12 | * License, or (at your option) any later version. |
||
13 | * |
||
14 | * This program is distributed in the hope that it will be useful, |
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | * GNU Affero General Public License for more details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU Affero General Public License |
||
20 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
21 | */ |
||
22 | |||
23 | declare(strict_types=1); |
||
24 | |||
25 | namespace App\Http\Controllers; |
||
26 | |||
27 | use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
||
28 | use Illuminate\Foundation\Bus\DispatchesJobs; |
||
29 | use Illuminate\Foundation\Validation\ValidatesRequests; |
||
30 | use Illuminate\Routing\Controller as BaseController; |
||
31 | |||
32 | /** |
||
33 | * Class Controller. |
||
34 | */ |
||
35 | class Controller extends BaseController |
||
36 | { |
||
37 | use AuthorizesRequests, DispatchesJobs, ValidatesRequests; |
||
38 | |||
39 | /** |
||
40 | * Controller constructor. |
||
41 | */ |
||
42 | public function __construct() |
||
43 | { |
||
44 | $variables = [ |
||
45 | 'FIREFLY_III_ACCESS_TOKEN' => 'bunq.access_token', |
||
46 | 'FIREFLY_III_URI' => 'bunq.uri', |
||
47 | 'BUNQ_API_CODE' => 'bunq.api_code', |
||
48 | 'BUNQ_API_URI' => 'bunq.api_uri', |
||
49 | ]; |
||
50 | foreach ($variables as $env => $config) { |
||
51 | $value = (string) config($config); |
||
52 | if ('' === $value) { |
||
53 | echo sprintf('Please set a valid value for "%s" in the env file.', $env); |
||
54 | app('artisan')->call('config:clear'); |
||
55 | exit; |
||
0 ignored issues
–
show
|
|||
56 | } |
||
57 | } |
||
58 | if ( |
||
59 | false === strpos(config('bunq.uri'), 'http://') |
||
60 | && false === strpos(config('bunq.uri'), 'https://') |
||
61 | ) { |
||
62 | echo 'The URL to your Firefly III instance must begin with "http://" or "https://".'; |
||
63 | exit; |
||
0 ignored issues
–
show
|
|||
64 | } |
||
65 | |||
66 | app('view')->share('version', config('bunq.version')); |
||
67 | } |
||
68 | } |
||
69 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.