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(); //instanciando clase del indexController if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { $metodo = 'index'; } if ($args != null) { call_user_func_array(array($controller, $metodo), $args); //en un arreglo enviamos nombre de clase y metodo que queremos llamar y parametros que queremos pasar } else { call_user_func(array($controller, $metodo)); } } else { throw new Exception('Controller no encontrado: ' . $rutaControlador); } }
/** * inicio la jfuncion operatjiva del sistema * @param Request $peticion solicitud * @return none no retorna nada */ public static function run(Request $peticion) { $controller = $peticion->getControlador() . "Controller"; $rutaControlador = ROOT . "controllers" . DS . $controller . ".php"; $metodo = $peticion->getMetodo(); $args = $peticion->getArgs(); /*echo "<br>".$rutaControlador; exit;*/ 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), $peticion->getArgs()); } else { call_user_func(array($controller, $metodo)); } } else { throw new Exception("Controlador no encontrado"); } }
/** * function show * @param tablename,wherecondition,header of table * @return null, rendering a view with data * default view _crud/show */ public static function show($tablename, $items, $fields_header, $options = array()) { $number_objects = 20; $request = new Request(); $args = $request->getArgs(); $view = new View("_crud/show"); isset($options['title']) ? $view->title = $options['title'] : ($view->title = ""); // implemento le variabili per la vista $view->tableName = $tablename; $view->fields_header = $fields_header; $view->rows = $items; $view->text_noresult = "nessun dato trovato"; $view->link_edit = CRUD::getLink($tablename, "edit"); $view->link_delete = CRUD::getLink($tablename, "delete"); $view->link_add = CRUD::getLink($tablename, "add"); $view->link_view = CRUD::getLink($tablename, "view"); // tutte le componenti di options // diventano variabili della vista if (is_array($options) && count($options) > 0) { foreach ($options as $key => $value) { $view->{$key} = $value; } } /* * $message_text e message_type devono essere modificabili dal * controller di sys_user per un'eventuale informazione dopo un'azione */ // renderizzo la view $view->render(); }
public static function run(Request $peticion) { $controller = $peticion->getControlador() . 'Controller'; $metodo = $peticion->getMetodo(); $args = $peticion->getArgs(); $rutaControlador = ROOT . 'controllers' . DS . $controller . '.php'; // echo $rutaControlador; exit; /* Verifica si el archivo esta en la ruta que se manda, si existe y es valido lo importa */ if (is_readable($rutaControlador)) { require_once $rutaControlador; $controller = new $controller(); /* Si se envia un metodo que no es valido se llama al metodo index */ if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { $metodo = 'index'; } /* Verificar argumentos para llamar al controlador */ if (isset($args)) { /* En arreglo se envia el nombre, metodo y parametros. Se llama arreglo */ call_user_func_array(array($controller, $metodo), $args); } else { call_user_func(array($controller, $metodo)); } } else { header('location:' . BASE_URL . 'error/access/1210'); } }
public static function route(Request $request) { $controller = $request->getController() . 'Controller'; $method = $request->getMethod(); $args = $request->getArgs(); //$controllerFile = SITE_PATH.'controllers/'.$controller.'.php'; //***Because autoload //if(is_readable($controllerFile)){ //***Because autoload //require_once $controllerFile; //***Because autoload $controller = new $controller(); $method = is_callable(array($controller, $method)) ? $method : 'index'; if (!empty($args)) { //call_user_func_array(array($controller,$method),$args); if (extension_loaded('newrelic')) { newrelic_name_transaction((string) $request->getController() . '/' . (string) $method); } call_user_func(array($controller, $method), $args); } else { if (extension_loaded('newrelic')) { newrelic_name_transaction((string) $request->getController() . '/' . (string) $method); } call_user_func(array($controller, $method), NULL); } return; //} //***Because autoload throw new Exception('404 - ' . $request->getController() . ' not found'); }
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"); } }
public static function run($request) { if (!$request instanceof Request) { $request = new Request($request); } $file = $request->getFile(); $class = $request->getClass(); $method = $request->getMethod(); $args = $request->getArgs(); $front = FrontController::getInstance(); $registry = $front->getRegistry(); $registry->oRequest = $request; $front->setRegistry($registry); if (file_exists($file)) { require_once $file; $rc = new ReflectionClass($class); // if the controller exists and implements IController // if($rc->implementsInterface('IController')) if ($rc->isSubclassOf('BaseController')) { try { $controller = $rc->newInstance(); $classMethod = $rc->getMethod($method); return $classMethod->invokeArgs($controller, $args); } catch (ReflectionException $e) { throw new MvcException($e->getMessage()); } } else { // throw new MvcException("Interface iController must be implemented"); throw new MvcException("abstract class BaseController must be extended"); } } else { throw new MvcException("Controller file not found"); } }
/** * 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"); } }
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."; } }
public static function run(Request $peticion) { $controller = $peticion->getControlador() . 'Controller'; // ejem: indexController o postController $rutaControlador = ROOT . 'controllers' . DS . $controller . '.php'; // ejem: .../controllers/indexController.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 (isset($args)) { call_user_func_array(array($controller, $metodo), $args); } else { call_user_func(array($controller, $metodo)); } } else { throw new Exception('controlador no encontrado'); } }
public static function run(Request $peticion) { $modulo = $peticion->getModulo(); $controller = $peticion->getControlador() . 'Controller'; $metodo = $peticion->getMetodo(); $args = $peticion->getArgs(); if ($modulo) { $rutaModulo = ROOT . 'controllers' . DS . $modulo . 'Controller.php'; if (is_readable($rutaModulo)) { require_once $rutaModulo; $rutaControlador = ROOT . 'modules' . DS . $modulo . DS . 'controllers' . DS . $controller . '.php'; } else { throw new Exception('Error de base de modulo'); } } else { $rutaControlador = ROOT . 'controllers' . DS . $controller . '.php'; } if (is_readable($rutaControlador)) { require_once $rutaControlador; $controller = new $controller(); if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { $metodo = 'index'; } if (isset($args)) { call_user_func_array(array($controller, $metodo), $args); } else { call_user_func(array($controller, $metodo)); } } else { throw new Exception('no encontrado'); } }
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(isset($args)) call_user_func_array(array($controller,$metodo), $args); else call_user_func(array($controller,$metodo)); } else { throw new Exception('rutaControlador no encontrada'); } }
public static function run(Request $peticion) { $modulo = $peticion->getModulo(); $controller0 = $peticion->getControlador(); $controller = $controller0 . 'Controller'; $metodo = $peticion->getMetodo(); $args = $peticion->getArgs(); //throw new Exception($modulo.' '.$controller0.' '.$metodo); if ($modulo == false) { /* if($controller0 == false){ $folder = 'index'; }*/ $folder = $peticion->getFolder($controller0); } else { $folder = $peticion->getFolder($modulo); } //throw new Exception($folder); //si existe modulo entonces cargar el controlador del modulo if ($modulo) { $rutaModulo = ROOT . 'src' . DS . $folder . DS . '_modules' . DS . $modulo . DS . 'controllers' . DS . $controller . '.php'; //throw new Exception($rutaModulo); if (is_readable($rutaModulo)) { require_once $rutaModulo; $rutaControlador = ROOT . 'src' . DS . $folder . DS . '_modules' . DS . $modulo . DS . 'controllers' . DS . $controller . '.php'; } else { throw new Exception('Error de base de modulo'); } } else { $rutaControlador = ROOT . 'src' . DS . $folder . DS . 'controllers' . DS . $controller . '.php'; } //throw new Exception($rutaControlador); //si la ruta del controlador se puede leer, entonces se crea el controlador if (is_readable($rutaControlador)) { require_once $rutaControlador; //throw new Exception($rutaControlador . ' - ' . $controller); //Crea un nuevo objeto controllador, $controller = new $controller(); //se llama al metodo del controllador if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { //si no hay ningun metodo se llama all metodo index $metodo = 'index'; } // si hay argumentos entonces se llama al metodo con sus argumentos // PHP function: call_user_func if (isset($args)) { call_user_func_array(array($controller, $metodo), $args); } else { call_user_func(array($controller, $metodo)); } } else { //no se encuentra el controllador.. throw new Exception('no encontrado'); } }
public static function route(Request $request) { $controller = $request->getController() . 'Controller'; $method = $request->getMethod(); $args = $request->getArgs(); $controllerFile = SITE_PATH . 'controllers/' . $controller . '.php'; if (is_readable($controllerFile)) { require_once $controllerFile; $controller = new $controller(); $method = is_callable(array($controller, $method)) ? $method : 'index'; call_user_func(array($controller, $method)); } }
public static function route(Request $request) { $controller = $request->getController() . 'Controller'; $method = $request->getMethod(); $args = $request->getArgs(); $controllerFile = APP . 'controllers/' . $controller . '.php'; $controller = new $controller(); $method = is_callable(array($controller, $method)) ? $method : 'index'; if (!empty($args)) { call_user_func_array(array($controller, $method), $args); } else { call_user_func(array($controller, $method)); } return; }
/** * Fonction qui recupere le bon controlleur et la fonction * * @param Request $request * @return type * @throws Exception */ public static function route(Request $request) { $controller = $request->getController() . 'Controller'; $method = $request->getMethod(); $args = $request->getArgs(); $controllerFile = SITE_PATH . 'controllers/' . $controller . '.php'; if (is_readable($controllerFile)) { require_once $controllerFile; $controller = new $controller(); $method = is_callable(array($controller, $method)) ? $method : 'index'; if (!empty($args)) { call_user_func_array(array($controller, $method), $args); } else { call_user_func(array($controller, $method)); } return; } throw new Exception('404 - ' . $request->getController() . ' not found'); }
public function __construct(Request $peticion) { //$peticion es un objeto de Request $this->_controlador = $peticion->getControlador(); //$this->_request = $peticion; $this->_js = array(); $this->_rutas = array(); $this->_args = $peticion->getArgs(); /*$modulo = $this->_request->getModulo(); $controlador= $this->_request->getControlador(); if($modulo) { $this->_rutas['view'] = ROOT . 'modules' . DS . $modulo . DS . 'views' . DS . $controlador . DS; $this->_rutas['js'] = BASE_URL . 'modules/' . $modulo . '/views/' . $controlador . '/js/'; } else { $this->_rutas['view'] = ROOT . 'views' . DS . $controlador . DS; $this->_rutas['js'] = BASE_URL . 'views/' . $controlador . '/js/'; }*/ }
public static function run(Request $request) { // Obtêm os segmentos da URL a partir do objeto $request $controlador = $request->getControlador(); $metodo = $request->getMetodo(); $args = (array) $request->getArgs(); if (!empty($request::getModules())) { $controlador = 'Application\\' . ucfirst($request::getModules()) . '\\Controller\\' . ucfirst($controlador) . '\\' . ucfirst($controlador); } else { $controlador = 'Application\\Front\\Controller\\' . ucfirst($controlador) . '\\' . ucfirst($controlador); } if ($controlador instanceof $controlador == FALSE) { $controlador = new $controlador(); } if (!is_callable(array($controlador, $metodo))) { self::error("Método - O método {$metodo} não existe !"); return; } call_user_func_array(array($controlador, $metodo), $args); }
public static function run(Request $peticion) { $controllerFiltro = $peticion->getControlador(); $controllerComodin = $peticion->getComodin(); $controller = $peticion->getControlador() . 'Controller'; // ejem: indexController o postController if ($controllerComodin == "frontend") { $rutaControlador = ROOT . 'controllers' . DS . 'frontend' . DS . $controller . '.php'; // ejem: .../controllers/frontend/indexController.php } elseif ($controllerComodin == "backend") { $rutaControlador = ROOT . 'controllers' . DS . 'backend' . DS . $controller . '.php'; // ejem: .../controllers/backend/indexController.php } else { $rutaControlador = ROOT . 'controllers' . DS . 'frontend' . DS . $controller . '.php'; // ejem: .../controllers/indexController.php } //$rutaControlador = ROOT . 'controllers' . DS . $controller . '.php'; // ejem: .../controllers/indexController.php $metodo = $peticion->getMetodo(); $args = $peticion->getArgs(); // echo "controller comodín: ".$controllerComodin."<br>"; // echo "ruta controlador: ".$rutaControlador."<br>"; // echo "controlador: ".$controller."<br>"; // echo "metodo: ".$metodo."<br>"; // echo "arguentos: ".$args."<br>"; if (is_readable($rutaControlador)) { require_once $rutaControlador; $controller = new $controller(); if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { $metodo = 'index'; } if (isset($args)) { call_user_func_array(array($controller, $metodo), $args); } else { call_user_func(array($controller, $metodo)); } } else { throw new Exception('no encontrado'); } }
public static function run(Request $request) { $controller = $request->getController() . 'Controller'; $routeController = ROOT . 'Controllers' . DS . $controller . '.php'; $method = $request->getMethod(); $args = $request->getArgs(); if (is_readable($routeController)) { require_once $routeController; $controller = new $controller(); if (!is_callable(array($controller, $method))) { $method = 'index'; } if ($args != null) { call_user_func_array(array($controller, $method), $args); } else { call_user_func(array($controller, $method)); } } else { throw new Exception('no encontrado xD'); } }
public static function run(Request $peticion) { $controlador = ucwords($peticion->getControlador() . 'Controller'); $rutaControlador = ROOT . 'controllers' . DS . $controlador . '.php'; $metodo = ucfirst($peticion->getMetodo()); $args = $peticion->getArgs(); if (is_readable($rutaControlador)) { require_once $rutaControlador; $controller = new $controlador(); if (is_callable(array($controller, $metodo))) { $metodo = $peticion->getMetodo(); } else { $metodo = 'index'; } if (sizeof($args) > 0) { call_user_func_array(array($controller, $metodo), $args); } else { call_user_func(array($controller, $metodo)); } } else { header('Location: /?uri=error/access/404'); } }
/** * @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"); } }
/** * function route * @param Registry instance */ public static function route(Request $r) { // recupero tutti i parametri dalla richiesta $controller = $r->getController(); $method = $r->getMethod(); $args = $r->getArgs(); // se il controller è leggibile $controller_path = PATH_Controllers . DS . sprintf("controller.%s.php", $controller); if (is_readable($controller_path)) { // includo e istanzio il controller require_once $controller_path; $controller_n = $controller . "Controller"; $controller = new $controller_n(); // controllo istanza del metodo if ($controller instanceof AppController) { // cerco il metodo if (method_exists($controller, $method)) { if (!empty($args)) { call_user_func_array(array($controller, $method), $args); } else { call_user_func(array($controller, $method)); } } else { call_user_func(array($controller, "error_404")); } } else { throw new Exception("Impossibile lavorare con oggetti di classi diverse da AppController"); } } else { $controller_path = PATH_Controllers . DS . "controller." . DEFAULT_CONTROLLER . ".php"; require_once $controller_path; $controller_n = DEFAULT_CONTROLLER . "Controller"; $controller = new $controller_n(); call_user_func(array($controller, "error_404")); } }
public static function run(Request $getRequest) { $controller = $getRequest->getController() . 'Controller'; $rootController = ROOT . 'controllers' . DS . $controller . '.php'; $method = $getRequest->getMethod(); $args = $getRequest->getArgs(); if (is_readable($rootController)) { require $rootController; $controller = new $controller(); if (is_callable(array($controller, $method))) { $method = $getRequest->getMethod(); } else { $method = 'index'; } if (isset($args)) { call_user_func_array(array($controller, $method), $args); } else { call_user_func(array($controller, $method)); } } else { include 'public/error/404.php'; // SHOW ERROR 404 } }