|
@@ -37,7 +37,7 @@ class LuticateApplication implements MessageComponentInterface
|
37
|
37
|
*/
|
38
|
38
|
public function __construct($configuration)
|
39
|
39
|
{
|
40
|
|
- error_reporting(0);
|
|
40
|
+ ini_set("display_errors", "stderr");
|
41
|
41
|
$this->_config = $configuration;
|
42
|
42
|
$this->_clients = new \SplObjectStorage;
|
43
|
43
|
$this->_router = new LuRoute();
|
|
@@ -84,34 +84,10 @@ class LuticateApplication implements MessageComponentInterface
|
84
|
84
|
|
85
|
85
|
$this->_router->setup();
|
86
|
86
|
}
|
87
|
|
-
|
88
|
|
- public function getDatabases()
|
89
|
|
- {
|
90
|
|
- return $this->_config['databases'];
|
91
|
|
- }
|
92
|
87
|
|
93
|
|
- public function setupDatabases()
|
|
88
|
+ public function addDatabaseProvider($dbProviderClass)
|
94
|
89
|
{
|
95
|
|
- $capsule = new Capsule;
|
96
|
|
- foreach (static::getDatabases() as $database) {
|
97
|
|
-
|
98
|
|
- if ($database['driver'] == 'pgsql' || $database['driver'] == 'mysql' ||
|
99
|
|
- $database['driver'] == 'sqlite' || $database['driver'] == 'sqlsrv') {
|
100
|
|
- $default = [
|
101
|
|
- 'name' => 'mydb',
|
102
|
|
- 'host' => '172.17.0.1',
|
103
|
|
- 'database' => 'luticate2',
|
104
|
|
- 'username' => 'dev',
|
105
|
|
- 'password' => 'dev',
|
106
|
|
- 'charset' => 'utf8',
|
107
|
|
- 'collation' => 'utf8_unicode_ci',
|
108
|
|
- 'prefix' => ''
|
109
|
|
- ];
|
110
|
|
- $db = array_merge($default, $database);
|
111
|
|
- $capsule->addConnection($db, $database['name']);
|
112
|
|
- }
|
113
|
|
- }
|
114
|
|
- $capsule->setAsGlobal();
|
|
90
|
+ call_user_func([$dbProviderClass, "setupDatabases"], $this->_config['databases']);
|
115
|
91
|
}
|
116
|
92
|
|
117
|
93
|
private function dispatch($httpMethod, $url, $parameters)
|