Example #1
0
 function load()
 {
     $num = Conf::$user["role"];
     $compteurarray = null;
     do {
         do {
             $role = Conf::$numerorole[$num];
             if (is_array($role)) {
                 if (is_null($compteurarray)) {
                     $compteurarray = 0;
                 }
                 $r = $role;
                 $role = $role[$compteurarray];
                 $compteurarray++;
                 if ($compteurarray == count($r)) {
                     $compteurarray = null;
                     $num--;
                 }
             } else {
                 $num--;
             }
             if ($role === \config\Conf::$numerorole[1]) {
                 $cname = '\\controller\\' . ucfirst($this->request->controller);
             } else {
                 $cname = '\\controller\\' . strtolower($role) . '\\' . ucfirst($this->request->controller);
             }
         } while (!file_exists(ROOT . DS . str_replace("\\", DS, $cname) . ".php") && $num > 0);
         Conf::$rolevue = strtolower($role);
         $controller = new $cname($this->request, $this->debug);
     } while (!in_array($this->request->action, get_class_methods($controller)) && $num > 0);
     if (!in_array($this->request->action, get_class_methods($controller))) {
         trigger_error("Le controller " . $this->request->controller . " n'a pas de méthode " . $this->request->action);
         $this->error("Le controller " . $this->request->controller . " n'a pas de méthode " . $this->request->action);
     }
     /*$r = new \ReflectionMethod($controller, $this->request->action);
             $params = $r->getParameters();
             foreach ($params as $param) {
                 //$param is an instance of ReflectionParameter
                 echo $param->getName() . "<br>";
                 echo $param->isOptional() . "<br>";
             }
             var_dump($this->request->params);
             var_dump($_GET);
             var_dump($this->request);
             die();
     */
     call_user_func_array(array($controller, $this->request->action), $this->request->params);
     $controller->render($this->request->action);
 }