-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathApp.php
75 lines (70 loc) · 2.01 KB
/
App.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
<?php
/**
* App
*
* @category BEAR
* @package BEAR.app
* @author $Author:$ <[email protected]>
* @license @license@ http://@license_url@
* @version Release: @package_version@ $Id:$
* @link http://@link_url@
*/
/**
* App root path
*/
define('_BEAR_APP_HOME', realpath(dirname(__FILE__)));
// composer auto load
require_once __DIR__ . '/vendor/autoload.php';
require_once 'BEAR.php';
$bearMode = isset($_SERVER['bearmode']) ? $_SERVER['bearmode'] : 0;
// profile
//include 'BEAR/Dev/Profile/script/startxh.php'; //xhprof
App::init($bearMode);
/**
* App
*
* @category BEAR
* @package BEAR.app
* @subpackage Db
* @author $Author:$ <[email protected]>
* @license @license@ http://@license_url@
* @version Release: @package_version@ $Id:$
* @link http://@link_url@
*/
class App
{
/**
* App init
*
* @param int $bearMode
*
* @return void
*/
public static function init($bearMode = 1)
{
$app = BEAR::loadConfig(_BEAR_APP_HOME . '/App/app.yml');
switch ($bearMode) {
case 1 :
//debug mode (cache disabled)
$app['BEAR_Cache']['adapter'] = 0;
case 2 :
//debug mode (cache enabled)
$app['core']['debug'] = true;
$app['App_Db']['dsn']['default'] = $app['App_Db']['dsn']['slave'] = $app['App_Db']['dsn']['test'];
$app['BEAR_Ro_Prototype']['__class'] = 'BEAR_Ro_Prototype_Debug';
break;
case 100:
// for UNIT test or HTTP access test
$app['core']['debug'] = false;
$app['App_Db']['dsn']['default'] = $app['App_Db']['dsn']['slave'] = $app['App_Db']['dsn']['test'];
$app['BEAR_Resource_Request']['__class'] = 'BEAR_Resource_Request_Test';
break;
case 0 :
default :
// live
$app['core']['debug'] = false;
break;
}
BEAR::init($app);
}
}