public static function ControllerSeeker($ctrl, $act, $param)
 {
     $controller = $ctrl;
     $action = $act;
     $parameters = $param;
     //Annotation parser is check for any valid annotation and return correct controller and action if it's need it;
     $annotationParameters = annotationParser::CheckAnnotations($controller, $action);
     $annotations = false;
     if (count($annotationParameters) > 0) {
         $controller = $annotationParameters["controller"];
         $action = $annotationParameters["action"];
         $annotations = true;
     }
     $customRouteParameters = CustomRouteController::routeChecker($controller, $action);
     if (!$annotations && !empty($customRouteParameters)) {
         $controller = $customRouteParameters["controller"];
         $action = $customRouteParameters["action"];
     }
     $controllerPath = "controllers\\defaultControllers\\" . ucfirst($controller) . "Controller";
     if (file_exists($controllerPath . ".php")) {
         spl_autoload_register(function ($class) {
             if (file_exists($class . ".php")) {
                 require_once $class . ".php";
             }
         });
         \views\View::$controllerName = $controller;
         \views\View::$actionName = $action;
         $currentController = new $controllerPath();
         if (true) {
             \MainMenuHelper::$menuitems = array("TestK" => "TestV");
         }
         if (method_exists($currentController, $action)) {
             call_user_func_array(array($currentController, $action), array($parameters));
         }
     } else {
         throw new \HttpException("NOT FOUND ROUTE!");
     }
 }
Пример #2
0
            if ($currentController == $requestUri[0] && $newSet != "") {
                var_dump($currentController);
                $requestUri[0] = 'error';
                $action = 'error';
            }
            if ($newSet == $requestUri[0]) {
                $requestUri[0] = $currentController;
            }
        }
        $controllerChecker = "controllers\\" . ucfirst($requestUri[0]) . "Controller.php";
        if (file_exists($controllerChecker)) {
            $controller = array_shift($requestUri);
            $actionchecker = array_shift($requestUri);
            $action = $actionchecker != null ? $actionchecker : 'index';
            $params = $requestUri;
        }
    }
}
$controllerName = "controllers\\" . ucfirst($controller) . "Controller";
spl_autoload_register(function ($class) {
    $controllerPath = $class . '.php';
    if (file_exists($controllerPath)) {
        require_once $controllerPath;
    }
});
views\View::$actionName = $action;
views\View::$controllerName = $controller;
$loadedConroller = new $controllerName();
if (method_exists($loadedConroller, $action)) {
    call_user_func_array(array($loadedConroller, $action), array($params));
}