-
Notifications
You must be signed in to change notification settings - Fork 65
/
recess-config.php
132 lines (96 loc) · 3.18 KB
/
recess-config.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php if(!isset($_ENV['dir.base'])) exit;
/* BEGIN RECESS APPS CONFIGURATION SETTINGS */
Config::$mode = Config::DEVELOPMENT;
Config::$useTurboSpeed = false; // I wanna go FAST!
Config::$cacheProviders
= array( 'Apc',
// 'Memcache',
// 'Disk'
);
Config::$applications
= array( 'frontend.FrontEndApplication',
'backend.BackEndApplication',
'recess.apps.ide.RecessIdeApplication',
'blog.BlogApplication'
);
//Config::$plugins
// = array( 'lib.recess.framework.plugins.ContentCaching'
// );
Config::$defaultDataSource
= array( 'sqlite:' . $_ENV['dir.base'] . '/data/default.db'
);
//Config::$namedDataSources
// = array( 'name' => array('dsn'),
// 'name' => array('dsn','user','pass','options')
// );
Config::$settings
= array( 'dir.temp' => $_ENV['dir.base'] . 'temp/',
'dir.test' => $_ENV['dir.base'] . 'test/',
'dir.apps' => $_ENV['dir.base'] . 'apps/'
);
/* END OF BASIC CONFIGURATION SETTINGS */
abstract class Config {
const DEVELOPMENT = 0;
const DEPLOYMENT = 1;
public static $mode = self::DEPLOYMENT;
public static $useTurboSpeed = false;
public static $cacheProviders = array();
public static $applications = array();
public static $plugins = array();
public static $defaultDataSource = array();
public static $namedDataSources = array();
public static $settings = array();
public static $policy;
static function init() {
if(self::$useTurboSpeed) {
Library::$useNamedRuns = true;
$cacheProvidersReversed = array_reverse(self::$cacheProviders);
foreach($cacheProvidersReversed as $provider) {
$provider = $provider . 'CacheProvider';
Cache::reportsTo(new $provider);
}
Cache::clear();
}
if(isset(self::$settings['dir.temp'])) {
$_ENV['dir.temp'] = self::$settings['dir.temp'];
} else {
$_ENV['dir.temp'] = $_ENV['dir.base'] . 'temp/';
}
if(!isset(self::$settings['dir.test'])) {
$_ENV['dir.test'] = self::$settings['dir.test'];
} else {
$_ENV['dir.test'] = $_ENV['dir.base'] . 'test/';
}
if(!isset(self::$settings['dir.apps'])) {
$_ENV['dir.apps'] = self::$settings['dir.apps'];
} else {
$_ENV['dir.apps'] = $_ENV['dir.base'] . 'apps/';
}
Library::init();
Library::beginNamedRun('recess');
Library::addClassPath(self::$settings['dir.apps']);
// TODO: GET RID OF THIS
Library::import('recess.framework.Application');
self::$applications = array_map(create_function('$class','return Library::importAndInstantiate($class);'),Config::$applications);
Library::import('recess.sources.db.DbSources');
Library::import('recess.sources.db.orm.ModelDataSource');
DbSources::setDefaultSource(new ModelDataSource(Config::$defaultDataSource[0]));
Library::import('recess.framework.DefaultPolicy');
self::$policy = new DefaultPolicy();
}
static function getRouter() {
Library::import('recess.framework.routing.RoutingNode');
Library::import('recess.framework.routing.Route');
$router = Cache::get('router');
if($router === false) {
$router = new RoutingNode();
foreach(self::$applications as $app) {
$app->addRoutesToRouter($router);
}
Cache::set('router', $router);
}
return $router;
}
}
Config::init();
?>