/
Bootstrap.php
84 lines (68 loc) · 2.59 KB
/
Bootstrap.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
private $_config;
/*get a copy of the config*/
public function _initBootstrap(){
$this->_config = Yaf_Application::app()->getConfig();
}
/*
* initIncludePath is only required because zend components have a shit load of
* include_once calls everywhere. Other libraries could probably just use
* the autoloader (see _initNamespaces below).
*/
public function _initIncludePath(){
set_include_path(get_include_path() . PATH_SEPARATOR . $this->_config->application->library);
}
public function _initErrors(){
if($this->_config->application->showErrors){
error_reporting (-1);
ini_set('display_errors','On');
}
}
public function _initNamespaces(){
Yaf_Loader::getInstance()->registerLocalNameSpace(array("Zend"));
Yaf_Loader::getInstance()->registerLocalNameSpace(array("Eyaf"));
}
public function _initRoutes(){
//this does nothing useful but shows the regex router in action...
Yaf_Dispatcher::getInstance()->getRouter()->addRoute(
"paging_example",
new Yaf_Route_Regex(
"#^/index/page/(\d+)#",
array('controller' => "index"),
array(1 => "page")
)
);
}
public function _initDefaultDbAdapter(){
$dbAdapter = new Zend_Db_Adapter_Pdo_Sqlite(
$this->_config->database->params->toArray()
);
Zend_Db_Table::setDefaultAdapter($dbAdapter);
}
public function _initLayout(Yaf_Dispatcher $dispatcher){
/*layout allows boilerplate HTML to live in /views/layout rather than every script*/
$layout = new LayoutPlugin('layout.phtml');
/* Store a reference in the registry so values can be set later.
* This is a hack to make up for the lack of a getPlugin
* method in the dispatcher.
*/
Yaf_Registry::set('layout', $layout);
/*add the plugin to the dispatcher*/
$dispatcher->registerPlugin($layout);
}
public function _initCssMinifier(){
$minifier = new Eyaf_Minify(new Eyaf_Minify_Strategy_Css());
$minifier->minifyDir(
$this->_config->static->css->sourceDir,
$this->_config->static->css->minDir
);
}
public function _initJsMinifier(){
$minifier = new Eyaf_Minify(new Eyaf_Minify_Strategy_Js());
$minifier->minifyDir(
$this->_config->static->js->sourceDir,
$this->_config->static->js->minDir
);
}
}