當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dispatcher::_controller方法代碼示例

本文整理匯總了PHP中Dispatcher::_controller方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dispatcher::_controller方法的具體用法?PHP Dispatcher::_controller怎麽用?PHP Dispatcher::_controller使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Dispatcher的用法示例。


在下文中一共展示了Dispatcher::_controller方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * Realiza el dispatch de una ruta
  *
  * @return Object
  */
 public static function execute($route)
 {
     extract($route, EXTR_OVERWRITE);
     if (!(include_once APP_PATH . "controllers/{$controller_path}" . '_controller.php')) {
         throw new KumbiaException(NULL, 'no_controller');
     }
     //Asigna el controlador activo
     $app_controller = Util::camelcase($controller) . 'Controller';
     $cont = self::$_controller = new $app_controller($module, $controller, $action, $parameters);
     View::select($action);
     View::setPath($controller_path);
     // Se ejecutan los filtros before
     if ($cont->k_callback('initialize') === FALSE) {
         return $cont;
     }
     if ($cont->k_callback('before_filter') === FALSE) {
         return $cont;
     }
     //Se ejecuta el metodo con el nombre de la accion
     //en la clase de acuerdo al convenio
     if (!method_exists($cont, $action)) {
         throw new KumbiaException(NULL, 'no_action');
     }
     //Obteniendo el metodo
     $reflectionMethod = new ReflectionMethod($cont, $action);
     //k_callback y __constructor metodo reservado
     if ($reflectionMethod->name == 'k_callback' || $reflectionMethod->isConstructor()) {
         throw new KumbiaException('Esta intentando ejecutar un método reservado de KumbiaPHP');
     }
     //se verifica que el metodo sea public
     if (!$reflectionMethod->isPublic()) {
         throw new KumbiaException(NULL, 'no_action');
     }
     //se verifica que los parametros que recibe
     //la action sea la cantidad correcta
     $num_params = count($parameters);
     if ($cont->limit_params && ($num_params < $reflectionMethod->getNumberOfRequiredParameters() || $num_params > $reflectionMethod->getNumberOfParameters())) {
         throw new KumbiaException("Número de parámetros erroneo para ejecutar la acción \"{$action}\" en el controlador \"{$controller}\"");
     }
     $reflectionMethod->invokeArgs($cont, $parameters);
     //Corre los filtros after
     $cont->k_callback('after_filter');
     $cont->k_callback('finalize');
     //Si esta routed volver a ejecutar
     if (Router::getRouted()) {
         Router::setRouted(FALSE);
         return Dispatcher::execute(Router::get());
         // Vuelve a ejecutar el dispatcher
     }
     return $cont;
 }
開發者ID:albertmolina,項目名稱:Daily-Content-Manager,代碼行數:56,代碼來源:dispatcher.php

示例2: execute

 /**
  * Realiza el dispatch de una ruta
  *
  * @return Object
  */
 public static function execute()
 {
     extract(Router::get(), EXTR_OVERWRITE);
     $controllers_dir = APP_PATH . 'controllers';
     if ($module) {
         $controllers_dir = $controllers_dir . '/' . $module;
     }
     $app_controller = Util::camelcase($controller) . 'Controller';
     $file = "{$controllers_dir}/{$controller}" . '_controller.php';
     if (!is_file($file)) {
         throw new KumbiaException(null, 'no_controller');
     }
     include_once $file;
     /**
      * Asigna el controlador activo
      **/
     self::$_controller = $activeController = new $app_controller($module, $controller, $action, $id, $all_parameters, $parameters);
     /**
      * Carga de modelos
      **/
     if (Config::get('config.application.database')) {
         if (Config::get('config.application.models_autoload')) {
             Load::models();
         } elseif ($activeController->models !== null) {
             Load::models($activeController->models);
         }
     }
     /**
      * Se ejecutan los filtros before
      */
     if ($activeController->initialize() === false) {
         return $activeController;
     }
     if ($activeController->before_filter() === false) {
         return $activeController;
     }
     /**
      * Se ejecuta el metodo con el nombre de la accion
      * en la clase
      */
     if (!method_exists($activeController, $action)) {
         throw new KumbiaException(null, 'no_action');
     }
     call_user_func_array(array($activeController, $action), $parameters);
     /**
      * Corre los filtros after
      */
     $activeController->after_filter();
     $activeController->finalize();
     /**
      * Elimino del controlador los modelos inyectados
      **/
     foreach (Load::get_injected_models() as $model) {
         unset($activeController->{$model});
     }
     /**
      * Limpia el buffer de modelos inyectados
      **/
     Load::reset_injected_models();
     return $activeController;
 }
開發者ID:raalveco,項目名稱:Escuela,代碼行數:66,代碼來源:dispatcher.php


注:本文中的Dispatcher::_controller方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。