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


PHP Dispatcher::getView方法代码示例

本文整理汇总了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();
 }
开发者ID:keradus,项目名称:ker,代码行数:52,代码来源:FrontController.php

示例2: getView

 /**
  * @return View
  */
 protected function getView()
 {
     return $this->_dispatcher->getView();
 }
开发者ID:zhxia,项目名称:nspf,代码行数:7,代码来源:Controller.php


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