Hatooz /
weather-module
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Configuration file for DI container. |
||
| 4 | */ |
||
| 5 | return [ |
||
| 6 | |||
| 7 | // Services to add to the container. |
||
| 8 | "services" => [ |
||
| 9 | "weatherservice" => [ |
||
| 10 | // Is the service shared, true or false |
||
| 11 | // Optional, default is true |
||
| 12 | "shared" => true, |
||
| 13 | |||
| 14 | // Is the service activated by default, true or false |
||
| 15 | // Optional, default is false |
||
| 16 | "active" => false, |
||
| 17 | |||
| 18 | // Callback executed when service is activated |
||
| 19 | // Create the service, load its configuration (if any) |
||
| 20 | // and set it up. |
||
| 21 | "callback" => function () { |
||
| 22 | $service = new \Anax\Service\WeatherService(); |
||
| 23 | |||
| 24 | // Load the configuration file(s) |
||
| 25 | $cfg = $this->get("configuration"); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 26 | $config = $cfg->load("weatherservice"); |
||
| 27 | // var_dump($config); |
||
| 28 | $settings = $config["config"] ?? null; |
||
| 29 | |||
| 30 | if ($settings["message"] ?? null) { |
||
| 31 | $service->setMessage($settings["message"]); |
||
| 32 | } |
||
| 33 | |||
| 34 | return $service; |
||
| 35 | } |
||
| 36 | ], |
||
| 37 | ], |
||
| 38 | ]; |
||
| 39 |