Toddez /
ramverk1-module
| 1 | <?php |
||
| 2 | |||
| 3 | return [ |
||
| 4 | "services" => [ |
||
| 5 | "weather" => [ |
||
| 6 | "callback" => function () { |
||
| 7 | $service = new \Teca\Weather\Weather(); |
||
| 8 | $service->setDi($this); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 9 | |||
| 10 | $cfg = $this->get('configuration'); |
||
| 11 | try { |
||
| 12 | $config = $cfg->load('api.php'); |
||
| 13 | $settings = $config['config'] ?? null; |
||
| 14 | $service->setApiKey($settings['openweatherKey']); |
||
| 15 | } catch (\Exception $e) { |
||
| 16 | if (!empty(getenv('openweatherKey'))) { |
||
| 17 | $service->setApiKey(getenv('openweatherKey')); |
||
| 18 | } else { |
||
| 19 | $service->setApiKey(''); |
||
| 20 | } |
||
| 21 | } |
||
| 22 | |||
| 23 | return $service; |
||
| 24 | } |
||
| 25 | ], |
||
| 26 | ], |
||
| 27 | ]; |
||
| 28 |