本文整理汇总了PHP中FrontController::retrieveControllerFileLocation方法的典型用法代码示例。如果您正苦于以下问题:PHP FrontController::retrieveControllerFileLocation方法的具体用法?PHP FrontController::retrieveControllerFileLocation怎么用?PHP FrontController::retrieveControllerFileLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrontController
的用法示例。
在下文中一共展示了FrontController::retrieveControllerFileLocation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
/**
* Static method that dispatches a controller based on the provided controller and action name
*
* @param string $controller the name of the controller without the trailing word Controller, e.g. Index as opposed to IndexController
* @param string $action the name of the action without the trailing word Action, e.g. index as opposed to indexAction
* @return object
*/
public static function dispatch($controller = "Index", $action = "index")
{
try {
$controllerName = $controller . "Controller";
$controllerLocation = FrontController::retrieveControllerFileLocation($controllerName);
if (!file_exists($controllerLocation)) {
throw new Exception($controllerName . ".class.php does not exist");
}
include $controllerLocation;
eval("\$object = new " . $controllerName . "();");
$object->__set("action", $action);
$object->__set("controller", $controller);
$object->__set("controllerName", $controllerName);
$object->__set("url", FrontController::retrieveURL());
$object->__set("method", FrontController::retrieveMethod());
$object->__set("model", FrontController::retrieveModel($controller));
$object->__set("view", new View($controller, $action));
if (method_exists($object, "initialize")) {
$annotationFactory = new AnnotationFactory($controllerLocation, "initialize");
$object->initialize();
}
return $object;
} catch (Exception $e) {
Functions::dump($e->getMessage());
return NULL;
}
}