Example #1
0
 private function Callback()
 {
     $ElementsRoute = explode('/', $this->bindParamRoute[0]);
     $routePremier = $this->bindParamRoute[0];
     unset($this->bindParamRoute[0]);
     $NbElements = count($ElementsRoute);
     $urlParam = '';
     for ($i = 0; $i < $NbElements; $i++) {
         $urlParam .= $this->bindParamClient[$i] . '/';
         unset($this->bindParamClient[$i]);
     }
     $urlParam = substr($urlParam, 0, -1);
     if ($urlParam == $routePremier) {
         if (!empty($this->bindParamRoute) and !empty($this->bindParamClient)) {
             $this->param = [];
             if (count($this->bindParamRoute) == count($this->bindParamClient)) {
                 $this->param = array_combine($this->bindParamRoute, $this->bindParamClient);
             } else {
                 if ($this->ErrorPage == FALSE) {
                     // Aucune route trouvée
                     $this->ErrorPage = 'param';
                     require_once 'ErrorPageController.class.php';
                     $ErrorPage = new ErrorPage();
                     return $ErrorPage->PageNoParametersRoute();
                 }
             }
         }
         $this->FileExisted();
         $this->ClassExisted();
         $method = $this->method . 'Route';
         if (method_exists($this->classOn, $method)) {
             if (!empty($this->param) and is_array($this->param)) {
                 $viewparam = '';
                 foreach ($this->param as $paramdebug) {
                     $viewparam .= $paramdebug . '/';
                 }
                 $this->urlTerminal = '<span class="dpm">Route: <kbd>' . $routePremier . '</kbd></span> <span class="dpm">Parameters: <kbd>' . $viewparam . '</kbd></span> <span class="dpm">Controller: <kbd>' . $this->controller . '</kbd></span> <span class="dpm">Method: <kbd>' . $this->method . '</kbd></span>';
                 return $this->classOn->{$method}($this->param);
             } else {
                 $this->urlTerminal = '<span class="dpm">Route: <kbd>' . $routePremier . '</kbd></span> <span class="dpm">Parameters: <kbd>N/A</kbd></span> <span class="dpm">Controller: <kbd>' . $this->controller . '</kbd></span> <span class="dpm">Method: <kbd>' . $this->method . '</kbd></span>';
                 return $this->classOn->{$method}();
             }
         } else {
             if ($this->ErrorPage == FALSE) {
                 // Aucune route trouvée
                 $this->ErrorPage = '404';
                 require_once 'ErrorPageController.class.php';
                 $ErrorPage = new ErrorPage();
                 return $ErrorPage->PageNotFoundRoute();
             }
         }
     }
 }