public static function run(Request $peticion) { $controller = $peticion->getControlador() . "Controller"; $rutaControlador = ROOT . "controllers" . DS . $controller . ".php"; $metodo = $peticion->getMetodo(); $args = $peticion->getArgs(); //echo $rutaControlador; //exit; if (is_readable($rutaControlador)) { require_once $rutaControlador; $Controlador = new $controller(); if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { $metodo = "index"; } if ($metodo == 'login' or $metodo == 'registro' or $metodo == 'busqueda' or $metodo == 'funcion' or $metodo == 'funcion' or $peticion->getControlador() == 'paginas') { # code... } else { Authorization::logged(); } if (isset($args)) { call_user_func_array(array($Controlador, $metodo), $args); } else { call_user_func(array($Controlador, $metodo)); } } else { throw new Exception("Controlador no encontrado"); } }
/** * run ejecuta clase Request * permite llamar una funcion sin necesidad de instanciar la clase * @param string $peticion parametro que se recibe de Request * @var string controller almacena controlador * @var string rutaControlador guarda ruta del controlador * @var string $metodo invoca a la funcion getMetodo de request * @var string $args invoca a la funcion getArgs de request * */ public static function run(Request $peticion) { $controller = $peticion->getControlador() . 'Controller'; $rutaControlador = ROOT . 'controllers' . DS . $controller . '.php'; $metodo = $peticion->getMetodo(); $args = $peticion->getArgs(); if (is_readable($rutaControlador)) { include_once $rutaControlador; $controlador = new $controller(); if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { $metodo = 'index'; } if ($metodo == 'login') { } else { Authorization::logged(); } if (isset($args)) { call_user_func_array(array($controlador, $metodo), $args); } else { call_user_func_array(array($controller, $metodo)); } } else { throw new Exception("Controlador no encontrado"); } }
/** * Clase Boostrap * Controlador para ver si estan disponibles los controladores. * * @author Rodibel Morales */ public static function run(Request $peticion) { $controller = $peticion->getControlador() . "Controller"; $rutaControlador = ROOT . "controllers" . DS . $controller . ".php"; $metodo = $peticion->getMetodo(); $args = $peticion->getArgs(); if (is_readable($rutaControlador)) { require_once $rutaControlador; $controller = new $controller(); if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { $metodo = "index"; } if ($metodo == "login") { } else { Authorization::logged(); } if (isset($args)) { call_user_func_array(array($controller, $metodo), $args); } else { call_user_func(array($controller, $metodo)); } } else { throw new Exception("Controlador no encontrado"); } }
/** * @author Karen <*****@*****.**> * @version 1.0 * @copyright karhega 2015 * * Execute run from the Class request * @param string $petition parameter that receives information from reques * @var string $controller stocks in controlador * @var string $rutaControlador saves the root from controlador * @var string $metodo invokes the function getMethod from request * @var string $args invokes the function gerArgs from Request * **/ public static function run(Request $peticion) { $controller = $peticion->getControlador() . 'Controller'; $rutaControlador = ROOT . 'controllers' . DS . $controller . '.php'; $metodo = $peticion->getMetodo(); $args = $peticion->getArgs(); /**Tells whether a file exists in $ruraControlador *and is readable **/ if (is_readable($rutaControlador)) { include_once $rutaControlador; $controlador = new $controller(); /** * Verifies that the contents can be called as a function */ if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { $metodo = 'index'; } if ($metodo == 'login') { } else { Authorization::logged(); } /** * isset - Determinates if the variable is sent and is not NULL * call_user_func_array - Calls a callback with an array of parameters */ if (isset($args)) { call_user_func_array(array($controlador, $metodo), $args); } else { call_user_func_array(array($controller, $metodo)); } } else { throw new Exception("Controlador no encontrado"); } }
$controller = ucwords($controller); $action = array_shift($url); $args = $url; } if (!isset($controller)) { $controller = "Users"; } if (!isset($action)) { $action = "index"; } if (empty($args)) { $args = array(0 => null); } if ($action == "login") { } else { Authorization::logged(); } $path = APP_PATH . DS . "Controllers" . DS . $controller . "Controller.php"; $view = APP_PATH . DS . "Views" . DS . $controller . DS . $action . ".php"; $header = APP_PATH . DS . "Views" . DS . "Layouts" . DS . "default" . DS . "header.php"; $footer = APP_PATH . DS . "Views" . DS . "Layouts" . DS . "default" . DS . "footer.php"; if (file_exists($path)) { include_once $path; $className = trim($controller, 's'); $ob = new $className(); if (isset($args)) { $ob->{$action}($args[0]); } else { $ob->{$action}(); } if (file_exists($view)) {