当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getController方法代码示例

本文整理汇总了PHP中Request::getController方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getController方法的具体用法?PHP Request::getController怎么用?PHP Request::getController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Request的用法示例。


在下文中一共展示了Request::getController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Run

 public static function Run(Request $request)
 {
     $controller = $request->getController() . 'Controller';
     $route = ROOT . '../' . 'app' . DS . 'Controllers' . DS . $controller . '.php';
     $method = $request->getMethod();
     if ($method == 'index.php') {
         $method = 'Index';
     }
     $parameters = $request->getParameters();
     if (is_readable($route)) {
         require_once $route;
         $function = "App\\Controllers\\" . $controller;
         $controller = new $function();
         if (!isset($parameters)) {
             $data = call_user_func(array($controller, $method));
         } else {
             $data = call_user_func_array(array($controller, $method), $parameters);
         }
     }
 }
开发者ID:GadgetsLab,项目名称:Metaherrera,代码行数:20,代码来源:Router.php

示例2: start

 public function start()
 {
     \org\equinox\utils\debug\DebugBarFactory::init();
     //$this->request->analyseAskedRequest();
     $controller = $this->getController($this->request->getModule(), $this->request->getController());
     try {
         try {
             $action = $controller->doActionRequested($this->request->action, 'main');
         } catch (\org\equinox\exception\AccessDeniedException $e) {
             if ($controller->getReturnType() == \org\equinox\controller\Controller::RETURN_TYPE_HTML) {
                 $controller = $this->getController($this->request->accessDeniedModule, $this->request->accessDeniedController);
                 $controller->doActionRequested($this->request->accessDeniedAction, 'main');
             } else {
                 echo $this->getJsonException($e);
             }
         }
     } catch (\Exception $e) {
         if ($controller->getReturnType() == \org\equinox\controller\Controller::RETURN_TYPE_HTML) {
             $this->request->exception = $e;
             $controller = $this->getController($this->request->errorModule, $this->request->errorController);
             $controller->doActionRequested($this->request->errorAction, 'main');
         } else {
             echo $this->getJsonException($e);
         }
     }
     if ($controller->getReturnType() == \org\equinox\controller\Controller::RETURN_TYPE_HTML) {
         $layout = $this->getController($this->request->layoutModule, $this->request->layoutController);
         echo $layout->genereLayout();
     } else {
         echo json_encode($action->getAllAssigns());
     }
     return true;
 }
开发者ID:rousseau-christopher,项目名称:equinox-core,代码行数:33,代码来源:FrontControllerImpl.php

示例3: route

 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');
 }
开发者ID:baconbao,项目名称:BaconBao_MVC_Framework_PHP,代码行数:26,代码来源:Router.class.php

示例4: run

 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.";
     }
 }
开发者ID:JoseDguez,项目名称:php-basic-project,代码行数:29,代码来源:router.php

示例5: run

 public static function run(Request $pedido)
 {
     $controller = ucfirst($pedido->getController());
     $caminho = ROOT . "controllers" . DS1 . $controller . DS1 . $controller . '.php';
     //        print $caminho;
     //        die;
     $metodo = $pedido->getMetodo();
     $parametro = $pedido->getParametros();
     if (is_readable($caminho)) {
         require $caminho;
         $controlador = ucfirst($controller);
         $namespace = "\\" . "controllers" . "\\" . $controlador;
         $controller = new $namespace();
         if (is_callable(array($controller, $metodo))) {
             $metodo = $pedido->getMetodo();
         } else {
             $metodo = "index";
         }
         if (isset($parametro)) {
             call_user_func_array(array($controller, $metodo), $parametro);
         } else {
             call_user_func(array($controller, $metodo));
         }
     } else {
         header("Location:" . URL . "error");
     }
 }
开发者ID:ndongalameck,项目名称:ceafieUan,代码行数:27,代码来源:Bootstrap.php

示例6: buildPath

 public static function buildPath(Request $peticion)
 {
     $module = $peticion->getModule();
     $controller = $peticion->getController();
     $path = CONTROLLER_PATH . $module . DS . $controller . '.php';
     return $path;
 }
开发者ID:alanRiveros,项目名称:minimalFrame,代码行数:7,代码来源:Router.php

示例7: __construct

 public function __construct()
 {
     // initialisation du CORE
     parent::__construct();
     $class = self::$curent_class;
     // appel du controlleur
     echo $class::{Request::getController() . 'Controller'}();
 }
开发者ID:bolchevian,项目名称:font,代码行数:8,代码来源:FontController.class.php

示例8: array

 function __construct(Request $pedido)
 {
     //parent::__construct();
     $this->_controller = $pedido->getController();
     //        print $this->_controller; exit;
     $this->_js = array();
     $this->_css = array();
 }
开发者ID:ndongalameck,项目名称:ceafieUan,代码行数:8,代码来源:View.php

示例9: handlerRequest

 function handlerRequest()
 {
     //require_once("C:\\xampp\\htdocs\\lesson3\\src\\core\\classes\\Request.php");
     //require_once("C:\\xampp\\htdocs\\lesson3\\src\\core\\classes\\Routing.php");
     var_dump("gtyftyftftf");
     $request = new Request();
     var_dump($request->getController());
     Routing::run($request);
 }
开发者ID:xenon-96-31-10,项目名称:phpMVClesson3,代码行数:9,代码来源:FrontController.php

示例10: route

 /**
  * 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');
 }
开发者ID:Bdiallo16,项目名称:Be,代码行数:26,代码来源:router.php

示例11: run

 /**
  * Run the application 
  * @param type $appBasePath
  */
 public function run($appBasePath)
 {
     /**
      * Define application base path
      */
     defined('APP_BASE_PATH') or define('APP_BASE_PATH', $appBasePath);
     /**
      * get controller and action from from url
      */
     $controller = Request::getController();
     $action = Request::getAction();
     /**
      * prepare controller class and path according to convention
      */
     $controllerClass = $controller . 'Controller';
     $controllerPath = APP_BASE_PATH . '/controllers/' . $controllerClass . '.php';
     /**
      * check if requested controller file and class exists
      * @todo use error controller and action to display errors
      */
     if (file_exists($controllerPath)) {
         /**
          * Include requested controller
          */
         include_once $controllerPath;
         if (class_exists($controllerClass)) {
             $Controller = new $controllerClass();
         } else {
             $msg = $controllerClass . ' class not found!';
             exit($msg);
         }
     } else {
         $msg = $controllerPath . ' not found!';
         exit($msg);
     }
     /**
      * prepare method
      */
     $methodName = $action . 'Action';
     if (!method_exists($Controller, $methodName)) {
         $msg = " Method {$methodName} not found on {$controllerClass} Class ";
         exit($msg);
     }
     /**
      * execute appropriate contoller's action method
      */
     try {
         $Controller->{$methodName}();
     } catch (Exception $exc) {
         Debug::r($exc->getMessage(), 'application-exception.txt');
     }
 }
开发者ID:santonil2004,项目名称:ovc,代码行数:56,代码来源:Application.php

示例12: route

 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));
     }
 }
开发者ID:0xevren,项目名称:MVC,代码行数:13,代码来源:router.php

示例13: run

 public static function run()
 {
     $request = new Request();
     $controller = $request->getController();
     $controllerPath = Router::buildPath($request);
     $action = $request->getAction();
     if (is_readable($controllerPath)) {
         require_once $controllerPath;
     } else {
         throw new Exception('no encontrado');
     }
     $controllerInstance = new $controller();
     $controllerInstance->{$action}();
 }
开发者ID:alanRiveros,项目名称:minimalFrame,代码行数:14,代码来源:Bootstrap.php

示例14: route

 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;
 }
开发者ID:douglastenn,项目名称:myown-php-micro-mvc,代码行数:15,代码来源:route.php

示例15: __get

 /**
  * Overriding parent
  *
  * @param string $name
  * @return mixed
  */
 public function __get($name)
 {
     if ($name == 'session') {
         if ($this->_session === null) {
             $req = $this->request;
             Loader::load('Session', 'core');
             $ns = $req->getController();
             $subdir = str_replace('/', '_', $req->getControllerSubDirectory());
             if ($subdir != '') {
                 $ns = $subdir . '_' . $ns;
             }
             $this->_session = new Session($ns);
         }
         return $this->_session;
     }
     if ($name == 'post') {
         if (!array_key_exists($name, $this->_caches)) {
             $this->_caches[$name] = $this->request->getPost();
         }
         return $this->_caches[$name];
     }
     if ($name == 'query') {
         if (!array_key_exists($name, $this->_caches)) {
             $this->_caches[$name] = $this->request->getQuery();
         }
         return $this->_caches[$name];
     }
     if ($name == 'params') {
         if (!array_key_exists($name, $this->_caches)) {
             $this->_caches[$name] = $this->request->getParams();
         }
         return $this->_caches[$name];
     }
     if ($name == 'controller') {
         if (!array_key_exists($name, $this->_caches)) {
             $this->_caches[$name] = $this->request->getController();
         }
         return $this->_caches[$name];
     }
     if ($name == 'action') {
         if (!array_key_exists($name, $this->_caches)) {
             $this->_caches[$name] = $this->request->getAction();
         }
         return $this->_caches[$name];
     }
     return parent::__get($name);
 }
开发者ID:2626suke,项目名称:curryfw,代码行数:53,代码来源:controller.php


注:本文中的Request::getController方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。