當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Renderer::setVars方法代碼示例

本文整理匯總了PHP中Renderer::setVars方法的典型用法代碼示例。如果您正苦於以下問題:PHP Renderer::setVars方法的具體用法?PHP Renderer::setVars怎麽用?PHP Renderer::setVars使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Renderer的用法示例。


在下文中一共展示了Renderer::setVars方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Dispatch
  */
 public function run()
 {
     $config = Service::get('config');
     $request = Service::get('request');
     $route = Service::get('router')->find($request->getUrl());
     $user = Service::get('user')->getUser();
     if (empty($user) & !empty(Cookie::get($config->getVal('remember/cookie_name')))) {
         $user = Service::get('user');
         $user = $user->find();
     }
     if (empty($user)) {
         if (!in_array($request->getUrl(), array('/login', '/auth', '/gate', '/register', '/reg'))) {
             $response = new RedirectResponse('/gate');
             $response->send();
         }
     }
     if (!empty($route)) {
         $controller_class = $route['controller'] . 'Controller';
         if (!class_exists($controller_class)) {
             throw new \Exception("Controller class [" . $route['controller'] . "] doesn't exist");
         }
         $controller = new $controller_class();
         if (!method_exists($controller, $route['action'] . 'Action')) {
             throw new \Exception("Method [" . $route['action'] . "Action ] doesn't exist in [" . $route['controller'] . "]");
         }
         $action = $route['action'] . 'Action';
         $response = call_user_func_array(array($controller, $action), $route['params']);
         if ($response->type == 'html') {
             $renderer = new Renderer(URL . '/src/template.php');
             $renderer->setVars(array('content' => $response->content));
             $response->content = $renderer->render();
         }
         $response->send();
     } else {
         throw new \Exception("Wrong route [" . $request->getUrl() . "]");
     }
 }
開發者ID:JavaTrain,項目名稱:train,代碼行數:40,代碼來源:Application.php


注:本文中的Renderer::setVars方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。