本文整理汇总了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() . "]");
}
}