SandraJinnevall /
ramverk1-module
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Anax\Ip3; |
||
| 4 | |||
| 5 | use Anax\Commons\ContainerInjectableInterface; |
||
| 6 | use Anax\Commons\ContainerInjectableTrait; |
||
| 7 | |||
| 8 | class IpController3 implements ContainerInjectableInterface |
||
| 9 | { |
||
| 10 | use ContainerInjectableTrait; |
||
| 11 | |||
| 12 | private $db = "not active"; |
||
| 13 | |||
| 14 | 1 | public function initialize() : void |
|
| 15 | { |
||
| 16 | 1 | $this->db = "active"; |
|
| 17 | 1 | $this->IpController = new Validera3(); |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 18 | 1 | } |
|
| 19 | |||
| 20 | 1 | public function indexAction() : object |
|
| 21 | { |
||
| 22 | 1 | $title = "Kontrollera IP"; |
|
| 23 | 1 | $show = true; |
|
| 24 | 1 | $ipController = $this->IpController; |
|
| 25 | 1 | $getcurrentIp = $ipController->getCurrentIP(); |
|
| 26 | 1 | $postion = $this->di->get("positionKey"); |
|
| 27 | 1 | $getcurrentCity = $postion->getPosition($getcurrentIp); |
|
| 28 | |||
| 29 | 1 | if ($this->di->get("request")->hasGet("ipadress")) { |
|
| 30 | 1 | $session = $this->di->get("session"); |
|
| 31 | 1 | $session->set("ipadress", $this->di->get("request")->getGet("ipadress")); |
|
| 32 | 1 | $resultIp = $this->checkIfValidOrNot(); |
|
| 33 | 1 | $this->di->get("page")->add("ip3/result3", $resultIp); |
|
| 34 | 1 | $show = false; |
|
| 35 | } |
||
| 36 | |||
| 37 | 1 | $this->di->get("page")->add("ip3/ip3", [ |
|
| 38 | 1 | "show" => $show, |
|
| 39 | 1 | "currentIP" => $getcurrentIp, |
|
| 40 | 1 | "currentCity" => $getcurrentCity[3], |
|
| 41 | ]); |
||
| 42 | 1 | return $this->di->get("page")->render([ |
|
| 43 | 1 | "title" => $title, |
|
| 44 | ]); |
||
| 45 | } |
||
| 46 | |||
| 47 | 1 | public function checkIfValidOrNot() |
|
| 48 | { |
||
| 49 | 1 | $ipcontroller = $this->IpController; |
|
|
0 ignored issues
–
show
|
|||
| 50 | 1 | $session = $this->di->get("session"); |
|
| 51 | 1 | $weather = $this->di->get("validera3"); |
|
| 52 | 1 | if ($session->has('ipadress')) { |
|
| 53 | 1 | $ipadress = $session->get("ipadress"); |
|
| 54 | 1 | $resultIp["ipadress"] = $ipadress; |
|
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 55 | 1 | $resultIp["validerbar"] = $weather->check($ipadress); |
|
| 56 | 1 | $resultIp["weatherForecast"] = $weather->getWeather($ipadress)["weatherForecast"]; |
|
| 57 | 1 | $resultIp["weatherHistory"] = $weather->getWeather($ipadress)["weatherHistory"]; |
|
| 58 | |||
| 59 | 1 | return $resultIp; |
|
| 60 | } |
||
| 61 | return []; |
||
| 62 | } |
||
| 63 | } |
||
| 64 |