public static function run(Request $request)
{
/** get the Controller, Method, Arguments/Parameters and the URL of the Controller */
$controller = $request->getController() . "Controller";
$method = $request->getMethod();
$args = $request->getArgs();
$controllerUrl = ROOT . "controllers" . DS . $controller . ".php";
if ($method == "index.php") {
$method = "index";
}
/** if the Controller exists, call the Controller */
if (is_readable($controllerUrl)) {
require_once $controllerUrl;
$fullController = "Controllers\\" . $controller;
$controller = new $fullController();
if (!isset($args)) {
$data = call_user_func(array($controller, $method));
} else {
$data = call_user_func_array(array($controller, $method), $args);
}
}
/** Render view */
$controllerUrl = ROOT . "views" . DS . $request->getController() . DS . $request->getMethod() . ".php";
if (is_readable($controllerUrl)) {
require_once $controllerUrl;
} else {
print "No se encontrĂ³ la ruta especificada.";
}
}