本文整理汇总了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);
}
}
}
示例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;
}
示例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');
}
示例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.";
}
}
示例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");
}
}
示例6: buildPath
public static function buildPath(Request $peticion)
{
$module = $peticion->getModule();
$controller = $peticion->getController();
$path = CONTROLLER_PATH . $module . DS . $controller . '.php';
return $path;
}
示例7: __construct
public function __construct()
{
// initialisation du CORE
parent::__construct();
$class = self::$curent_class;
// appel du controlleur
echo $class::{Request::getController() . 'Controller'}();
}
示例8: array
function __construct(Request $pedido)
{
//parent::__construct();
$this->_controller = $pedido->getController();
// print $this->_controller; exit;
$this->_js = array();
$this->_css = array();
}
示例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);
}
示例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');
}
示例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');
}
}
示例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));
}
}
示例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}();
}
示例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;
}
示例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);
}