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


PHP Router::getController方法代码示例

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


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

示例1: execute

 public function execute()
 {
     $suffix = "Controller";
     Router::parseUri();
     try {
         $_cc = ucfirst(Router::getController()) . $suffix;
         Loader::autoload($_cc);
         if (!class_exists($_cc, false) && !interface_exists($_cc, false)) {
             throw new Exception('Class ' . $_cc . ' does not exist');
         }
         $class = new ReflectionClass($_cc);
         if ($class->isAbstract()) {
             throw new Exception('Cannot create instances of abstract ' . $_cc . '');
         }
         // Create a new instance of the controller
         $controller = $class->newInstance();
         // Execute the "before action" method
         //$class->getMethod('before')->invoke($controller);
         // Execute the main action with the parameters
         $class->getMethod(Router::getAction() . 'Action')->invokeArgs($controller, Router::getParams());
         // Execute the "after action" method
         //$class->getMethod('after')->invoke($controller);
     } catch (Exception $e) {
         throw $e;
     }
     return $this;
 }
开发者ID:hexcode007,项目名称:yfcms,代码行数:27,代码来源:Request.class.php

示例2: run

 /**
  * This method launches the application.
  */
 public function run()
 {
     $router = new Router($this);
     $controller = $router->getController();
     $controller->execute();
     $this->response->setPage($controller->getPage());
     $this->response->send();
 }
开发者ID:rootfs,项目名称:robinhood,代码行数:11,代码来源:Application.class.php

示例3: init

 /**
  * 初始化
  * 
  */
 public function init()
 {
     $this->set('currentUrl', Request::currentUrl());
     $this->set('refererUrl', Request::refererUrl());
     $this->set('controller', Router::getController());
     $this->set('action', Router::getAction());
     $this->set('get', Request::getGet());
     $this->set('post', Request::getPost());
 }
开发者ID:Rgss,项目名称:imp,代码行数:13,代码来源:Tracer.php

示例4: dispatch

 public static function dispatch(Router $router)
 {
     // ob_start();
     $className = ucfirst($router->getController()) . 'Controller';
     $actionName = $router->getAction() . 'Action';
     $controllerFile = CONTROLLER_DIR . '/' . $className . '.class.php';
     if (file_exists($controllerFile)) {
         include_once $controllerFile;
         $app = new $className($router->getParams(), $router->getController());
         $app->{$actionName}();
         // $output = ob_get_clean();
         // echo $output;
     } else {
         // throw new Exception('Controller not found. className:['.$className.']');
         Log::fatal('Controller not found. className:[%s]', var_export($className, 1));
         trigger_error('Controller not found. className:[' . var_export($className, 1) . ']', E_USER_ERROR);
     }
 }
开发者ID:ToogleLiu,项目名称:too,代码行数:18,代码来源:Dispatcher.class.php

示例5: file_path

 private function file_path($tpl = null)
 {
     $tplDir = Router::getController();
     $tplName = isset($tpl) ? $tpl : Router::getAction();
     $templateFile = VIEW_DIR . $tplDir . DS . $tplName . '.phtml';
     if (!file_exists($templateFile)) {
         throw new Exception("{$templateFile} not found", 404);
     }
     return $templateFile;
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:10,代码来源:Controller.php

示例6: __construct

 public function __construct()
 {
     $this->controller = Router::getController();
     // get current controller
     $this->action = Router::getAction();
     // get current action/method
     // check if there is an ID on current route (URL)
     if (Router::hasID()) {
         $this->id = Router::getID();
         // get ID
     }
 }
开发者ID:rawswift,项目名称:Orinoco-Framework,代码行数:12,代码来源:controller.class.php

示例7: _call

 protected final function _call($path, $args = array())
 {
     $parts = explode('/', $path);
     if ($parts[0] == '') {
         array_shift($parts);
     }
     $router = new Router();
     $controller = $router->getController(new Context('controller', $parts[0], $parts[1], $args));
     if ($controller) {
         return $controller->_execute(false);
     }
     return false;
 }
开发者ID:RNKushwaha022,项目名称:orange-php,代码行数:13,代码来源:controller.class.php

示例8: run

 public function run()
 {
     if (Tipkin\Config::get('maintenance-mode') == 'on') {
         $this->httpResponse->redirect('/maintenance.html');
         exit;
     }
     $router = new Router($this);
     $controller = $router->getController();
     if (!is_null($controller)) {
         $controller->execute();
         $this->httpResponse->setPage($controller->page());
     }
 }
开发者ID:Tipkin-Commons,项目名称:tipkin,代码行数:13,代码来源:FrontendApplication.class.php

示例9: run

 public function run()
 {
     if ($this->user->isAdminAuthenticated()) {
         $router = new Router($this);
         $controller = $router->getController();
     } else {
         require dirname(__FILE__) . '/modules/connexion/ConnexionController.class.php';
         $controller = new ConnexionController($this, 'connexion', 'index');
     }
     if (!is_null($controller)) {
         $controller->execute();
         $this->httpResponse->setPage($controller->page());
     }
 }
开发者ID:Tipkin-Commons,项目名称:tipkin,代码行数:14,代码来源:BackendApplication.class.php

示例10: invokeController

 /**
  * Invoke controller based on URL structure
  */
 function invokeController()
 {
     $url = "";
     if (isset($_GET['url'])) {
         $url = $_GET['url'];
     }
     /** @var ControllerInterface $controller */
     $controller = Router::getController($url);
     if ((int) method_exists($controller, $controller->getAction() . 'Action')) {
         call_user_func_array(array($controller, $controller->getAction() . 'Action'), array());
     } else {
         /* Error Generation Code Here */
     }
 }
开发者ID:alebon,项目名称:url-shortener-php,代码行数:17,代码来源:Boot.php

示例11: displaySingle

 public function displaySingle($file = null, $data = null, $print = true)
 {
     if ($file == null) {
         throw new Exception('模板文件错误');
     }
     $file = Router::getController() . "/" . $file;
     if (is_array($data)) {
         foreach ($data as $k => $v) {
             $this->smarty->assign($k, $v);
         }
     }
     if ($print) {
         ob_start();
         $this->smarty->display($file . ".html");
         ob_end_flush();
         return;
     } else {
         return $this->smarty->fetch($file . ".html");
     }
 }
开发者ID:hexcode007,项目名称:yfcms,代码行数:20,代码来源:View.class.php

示例12: __construct

 public function __construct()
 {
     // parent::__construct();
     config::getInstance();
     config::getConfig();
     $router = new Router();
     $router->explodeUri();
     /*
     apenas para checagem dos caminhos
     //echo '<p>ROUT FILE: '.$routFile.'</p>';
     echo '<pre >';
     echo '<p>ROTA COMPLETA: '.$this->getRoute().'</p>';
     echo '<p>NOME Controller: '.$this->getController().'</p>';
     echo '<p>NOME METODO: '.$this->getAction().'</p>';
     echo '</pre>';
     */
     define('ROUTE', $router->getRoute());
     define('CONTROLLER', $router->getController());
     define('ACTION', $router->getAction());
     $filename = BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . ROUTE . CONTROLLER . '.controller.php';
     if (file_exists($filename)) {
         require_once $filename;
         $_controllerName = CONTROLLER;
         $_controller = new $_controllerName();
         $action = ACTION;
         if (method_exists($_controller, $action)) {
             $_controller->{$action}();
         } else {
             require_once BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . 'error404.controller.php';
             $errorController = new error404();
             $errorController->index();
         }
     } else {
         require_once BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . 'error404.controller.php';
         $errorController = new error404();
         $errorController->index();
     }
 }
开发者ID:Wellingtoncezar,项目名称:pfc,代码行数:38,代码来源:index.php

示例13: __construct

 public function __construct()
 {
     $this->controller = Router::getController();
 }
开发者ID:Accami,项目名称:BravelCMS,代码行数:4,代码来源:core.class.php

示例14: __autoload

<?php

//test
session_start();
$_SESSION['auth'] = 'user';
require_once 'router.php';
require_once 'baseController.php';
function __autoload($class)
{
    $class = './controllers/' . $class . '.php';
    require_once $class;
}
$router = new Router();
$controller = $router->getController();
$action = $router->getAction();
$obj = new $controller();
$obj->{$action}();
开发者ID:josephinesvasa,项目名称:GOD,代码行数:17,代码来源:index.php

示例15: defined

<?php

defined(SYS_PATH) or define("SYS_PATH", dirname(__FILE__) . "/");
require_once SYS_PATH . "classes/loader.php";
ini_set("display_errors", 1);
Loader::addAutoLoad();
Loader::addMap();
Registry::init();
Router::addMap();
Router::init();
var_dump(Router::getParams());
if (Router::getParams() == NULL) {
    Subdomain::init();
}
$controller = Router::getController();
$action = Router::getAction();
if ($controller == 'site' or $controller == 'admin' or $controller == 'stylecheet') {
    $controller::init($action);
} else {
    header("Location: http://myclankonto.net/");
}
开发者ID:homieforever,项目名称:MyClanKonto,代码行数:21,代码来源:init.php


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