示例#1
0
 public function _initConfig(Yaf\Dispatcher $dispatcher)
 {
     //把配置保存起来
     $this->config = Yaf\Application::app()->getConfig();
     Yaf\Registry::set('config', $this->config);
     define('REQUEST_METHOD', strtoupper($dispatcher->getRequest()->getMethod()));
 }
示例#2
0
 /**
  * 设置页面layout
  */
 public function _initLayout(Yaf\Dispatcher $dispatcher)
 {
     if (!$dispatcher->getRequest()->isXmlHttpRequest()) {
         $layout = new Layout($this->_config->application->layoutpath);
         $dispatcher->setView($layout);
     }
 }
示例#3
0
 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);
 }
示例#4
0
 public function _initConfig(Yaf\Dispatcher $dispatcher)
 {
     //把配置保存起来
     $this->config = Yaf\Application::app()->getConfig();
     Yaf\Registry::set('config', $this->config);
     define('REQUEST_METHOD', strtoupper($dispatcher->getRequest()->getMethod()));
     $this->lib = ini_get("yaf.library");
     Yaf\Registry::set('yafpath', $this->lib);
     Yaf\Registry::set('localLibrary', $this->config->application->library);
     Yaf\Loader::import($this->lib . "/SlatePF/Function.php");
     L("vendor/autoload.php");
 }
示例#5
0
 public function _initConfig(Yaf\Dispatcher $dispatcher)
 {
     //把配置保存起来
     $this->config = Yaf\Application::app()->getConfig();
     Yaf\Registry::set('config', $this->config);
     session_start();
     define('REQUEST_METHOD', strtoupper($dispatcher->getRequest()->getMethod()));
     define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
     define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
     define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
     define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
     define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ? true : false);
 }
示例#6
0
 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);
     }
 }