本文整理汇总了PHP中Dispatcher::getView方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::getView方法的具体用法?PHP Dispatcher::getView怎么用?PHP Dispatcher::getView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::getView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run()
{
$router = new Router();
$dispatcher = new Dispatcher($router, array("requireViewFile" => !in_array($router->getAction(), array_keys(static::$actionsWithDataOnly))));
static::$dispatcher =& $dispatcher;
$action = $dispatcher->getAction();
$controller = $dispatcher->getController();
$lang = $dispatcher->getLang();
$module = $dispatcher->getModule();
$permission = $dispatcher->getPermission();
$view = $dispatcher->getView();
$info = array("action" => $action, "controller" => $controller, "data" => $dispatcher->getData(), "extra" => $dispatcher->getExtra(), "lang" => $lang, "module" => $module, "view" => $view);
if ($permission::getPermission($action, Session::getPerm(), $info) === false) {
$dispatcher->setError(403);
$info["action"] = $action = $dispatcher->getAction();
$info["controller"] = $controller = $dispatcher->getController();
$info["module"] = $module = $dispatcher->getModule();
$info["view"] = $view = $dispatcher->getView();
}
//TASK: przeniesc do __constructStatic, znalezc inne wywolania __init i to samo!
$view::__init($action);
$view::obStart();
if (array_key_exists($action, static::$actionsWithDataOnly)) {
header("Content-Type: " . static::$actionsWithDataOnly[$action]);
//TODO: czy metody withDataOnly powinny otrzymywac argument $viewParams["info"] ?
if (is_callable(array($controller, $action))) {
echo $controller::$action();
} elseif (is_callable(array($controller, "{$action}_"))) {
$action2 = "{$action}_";
echo $controller::$action2();
}
} else {
if (Config::getOne("requireWww")) {
Utils\Header::redirectIfNotWww();
}
$viewParams = array("info" => $info);
// Troche magii:
// Jesli mamy modul, w ktorym akcja nazywa sie tak samo jak modul - to PHP uzna akcje za konstruktor, lecz ten nie moze byc statyczny wiec bedzie blad PHP.
// Wtedy definiujemy akcje jako z sufixem "_" (np. "AKCJA_"), a tu umozliwiamy jej wywolanie.
// Przyklad: \App\Controller\Index::index
if (is_callable(array($controller, $action))) {
$viewParams["data"] = $controller::$action($viewParams["info"]);
} elseif (is_callable(array($controller, "{$action}_"))) {
$action2 = "{$action}_";
$viewParams["data"] = $controller::$action2($viewParams["info"]);
}
$bodyContent = static::loadViewFile($view::getViewFile($lang, $module, $action), $viewParams);
$headerContent = static::loadViewFile($view::getViewFile($lang, "common", "header"), $viewParams);
$view::printSite(["bodyHeader" => $headerContent, "body" => $bodyContent, "info" => $info]);
}
$view::obFinish();
}
示例2: getView
/**
* @return View
*/
protected function getView()
{
return $this->_dispatcher->getView();
}