mahm17 /
ramverk1-module
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Anax\Weather; |
||
| 4 | |||
| 5 | use Anax\Commons\ContainerInjectableInterface; |
||
| 6 | use Anax\Commons\ContainerInjectableTrait; |
||
| 7 | |||
| 8 | class WeatherController implements ContainerInjectableInterface |
||
| 9 | { |
||
| 10 | use ContainerInjectableTrait; |
||
| 11 | |||
| 12 | 1 | public function indexAction() : object |
|
| 13 | { |
||
| 14 | 1 | $title = "Väder data"; |
|
| 15 | |||
| 16 | 1 | $page = $this->di->get("page"); |
|
| 17 | |||
| 18 | 1 | $page->add("weather/weather"); |
|
| 19 | |||
| 20 | 1 | return $page->render([ |
|
| 21 | 1 | "title" => $title, |
|
| 22 | ]); |
||
| 23 | } |
||
| 24 | |||
| 25 | 1 | public function validateAction() : object |
|
| 26 | { |
||
| 27 | 1 | $title = "Väder"; |
|
| 28 | 1 | $this->api = require ANAX_INSTALL_PATH . "/config/keys.php"; |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 29 | 1 | $this->address = $this->di->get("request")->getPost("address"); |
|
|
0 ignored issues
–
show
|
|||
| 30 | 1 | $page = $this->di->get("page"); |
|
| 31 | 1 | $curl = $this->di->get("curl"); |
|
| 32 | |||
| 33 | 1 | $curl->getIpData($this->address, $this->api["ip_key"]); |
|
| 34 | 1 | $curl->getWeatherData($this->api["weather_key"]); |
|
| 35 | |||
| 36 | 1 | $resOne = $curl->weatherData; |
|
| 37 | 1 | $resTwo = $curl->ipData; |
|
| 38 | 1 | $map = $curl->map; |
|
| 39 | |||
| 40 | 1 | $page->add("weather/weather_data", [ |
|
| 41 | 1 | "resOne" => $resOne, |
|
| 42 | 1 | "resTwo" => $resTwo, |
|
| 43 | 1 | "map" => $map, |
|
| 44 | ]); |
||
| 45 | |||
| 46 | 1 | return $page->render([ |
|
| 47 | 1 | "title" => $title, |
|
| 48 | ]); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |