colly_wyx
2018-04-20 6e54c31df658795ec830fc93a26cd6e3d910e2ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
    class Bootstrap extends Yaf_Bootstrap_Abstract{
        
 
        public function _init(Yaf_Dispatcher $dispatcher){
            Yaf_Session::getInstance()->start();
            $this->app = Yaf_Application::app();            
        }
 
        public function _initConfig(Yaf_Dispatcher $dispatcher) {
            $config = Yaf_Application::app()->getConfig();
            $this->config = $this->app->getConfig()->toArray();   
            $this->var = $this->config['var'];
            Yaf_Registry::set('var' , $this->var);
        }
 
        public function _initLoader(Yaf_Dispatcher $dispatcher){
            //注册本地类(先找项目library再找全局library)
            $loader = Yaf_Loader::getInstance();
            $loader->registerLocalNamespace(array('Service', 'Util', 'RedisCache'));
         //   print_r($loader);
        }
 
        public function _initService(Yaf_Dispatcher $dispatcher){
 
            $service = System_Service_Locator::getInstance();
            $service->set('db', 'System_Db_Mongo');
            $service->set('redis', 'RedisCache');
        }
 
        public function _initRoute(Yaf_Dispatcher $dispatcher){
            //$route_config = new Yaf_Config_Ini(APPLICATION_PATH.'/conf/routes.ini');
            //$router = Yaf_Dispatcher::getInstance()->getRouter();
            //$router->addConfig($route_config->routes);
            $router = Yaf_Dispatcher::getInstance()->getRouter();
            $route = new Yaf_Route_Rewrite('user_login.html',array('module'=>'public','controller' =>'user','action' => 'login'));
            $router->addRoute('product', $route);
        }
 
        public function _initPlugin(Yaf_Dispatcher $dispatcher){
             //注册布局插件
            $dispatcher->registerPlugin(new LayoutPlugin());
        }
    }