diff --git a/application/class/Application.php b/application/class/Application.php index 10bfe5e..a63e99f 100644 --- a/application/class/Application.php +++ b/application/class/Application.php @@ -26,8 +26,21 @@ class Application $this->url = new Url($this->http->method, $this->browser->isAppRequest()); - $dispacher = new Dispacher(); - $this->route = $dispacher->route; + switch(APP_STATE) { + case "CLOSED": + case "MAINTAINED": + $this->route = null; + break; + case "OPEN": + if(\MVC\Classe\Application::is_under_update()) { + $this->route = null; + break; + } + default: + $dispacher = new Dispacher(); + $this->route = $dispacher->route; + } + } public function launch() @@ -40,4 +53,15 @@ class Application \MVC\Object\Alert::remove(); } } + + public static function is_under_update(){ + $ajh = new \DateTime('NOW'); + $maintenance_begin = new \DateTime(MAINTENANCE_DATE_DEBUT); + $maintenance_fin = new \DateTime(MAINTENANCE_DATE_FIN); + if($maintenance_begin < $ajh && $ajh < $maintenance_fin) { + return true; + }else{ + return false; + } + } } diff --git a/application/class/Browser.php b/application/class/Browser.php index 99760ec..2971c1d 100644 --- a/application/class/Browser.php +++ b/application/class/Browser.php @@ -210,10 +210,22 @@ class Browser public function isAppRequest() { - if (preg_match('#App#', $this->user)) { - return true; - } else { - return false; + switch(APP_STATE) { + case "CLOSED": + case "MAINTAINED": + return false; + break; + case "OPEN": + if(\MVC\Classe\Application::is_under_update()) { + return false; + break; + } + default: + if (preg_match('#App#', $this->user)) { + return true; + } else { + return false; + } } } } diff --git a/application/class/Url.php b/application/class/Url.php index 2cdbede..6f9bd89 100644 --- a/application/class/Url.php +++ b/application/class/Url.php @@ -62,6 +62,22 @@ class Url unset($urlParts[1]); } + //Mise en place du statut de l'application + switch(APP_STATE){ + case "CLOSED": + $page['name'] = "error-application-closed"; + break; + case "MAINTAINED": + $page['name'] = "error-application-maintained"; + break; + case "OPEN": + if(\MVC\Classe\Application::is_under_update()) { + $page['name'] = "error-application-maintained"; + break; + } + default: + } + //vérification du nombre de parametres: $numParts = count($urlParts); //s'il n'existe pas autant de clé que de valeurs, ce peut ^etre un module symfony ou tout autre module diff --git a/application/config/app-parameters.php.skel b/application/config/app-parameters.php.skel index 6468c8d..d41d57a 100644 --- a/application/config/app-parameters.php.skel +++ b/application/config/app-parameters.php.skel @@ -1,5 +1,6 @@ +
+ Désolé pour cette gêne mais il se trouve que l'application est fermée à ce moment !
+
+ — Le service
+
+ application@localhost.fr
+
{{MAINTENANCE_MESSAGE}}+ @endif +
+ Désolé pour cette gêne mais il se trouve que l'application est en maintenance à ce moment !
+
+ — Le service
+
+ application@localhost.fr
+