<?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());
|
}
|
}
|