/** * 设置页面layout */ public function _initLayout(Yaf\Dispatcher $dispatcher) { if (!$dispatcher->getRequest()->isXmlHttpRequest()) { $layout = new Layout($this->_config->application->layoutpath); $dispatcher->setView($layout); } }
public function _initLayout(Yaf\Dispatcher $dispatcher) { $event = $this->profiler->startEvent('Init layout'); if (!$dispatcher->getRequest()->isXmlHttpRequest()) { $layout = new Layout($this->config->layout->dir); $dispatcher->setView($layout); } else { // } $this->profiler->endEvent($event); }
public function _initRest(Yaf\Dispatcher $dispatcher) { $dispatcher->disableView(); //如果不是cli就调用rest路由 if (!$dispatcher->getRequest()->isCli()) { $router = $dispatcher->getRouter(); $route = new RestRoute(); $router->addRoute("rest", $route); //设置模板目录 $view_engine = new Yaf\View\Simple(APPLICATION_PATH . '/application/views'); $dispatcher->setView($view_engine); //启用权限控制插件 $auth = new AuthPlugin(); $dispatcher->registerPlugin($auth); } else { $command = new CommandLinePlugin(); $dispatcher->registerPlugin($command); } }
public function _initView(Yaf\Dispatcher $dispatcher) { $view = new \SlatePF\Extras\ExtrasView(); $path = $view->getScriptPath(); // plain text TEST $view->on('txt', function ($file, $data) use($path) { return file_get_contents($path . $file) . ' THIS IS JUST A TEST'; }); // twig $view->on('twig', function ($file, $data) use($path) { $loader = new Twig_Loader_Filesystem($path); $twig = new Twig_Environment($loader); return $twig->loadTemplate($file)->render($data); }); //protobuf $view->on('pb', function ($file, $data) use($path) { include $path . $file; exit; }); $dispatcher->disableView(); // disable auto-render $dispatcher->setView($view); }
public function _initView(Yaf\Dispatcher $dispatcher) { $view = new \views\wittyAdapter(\Yaf\Registry::get("config")->witty); $dispatcher->setView($view); }
public function _initLayout(Yaf\Dispatcher $dispatcher) { $layout = new Layout($this->config->application->layout->directory); $dispatcher->setView($layout); }
/** * Using twig as templating engine * * @param Yaf_Dispatcher $dispatcher */ protected function _initView(Yaf\Dispatcher $dispatcher) { $view = new Cooltime\View\Twig(APPLICATION_PATH . "/application/views", Yaf\Application::app()->getConfig()->twig->toArray()); $dispatcher->setView($view); }