當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。