Configuration & Layout architecture updates
Fixed production bug Fixed styles Updated Action Controller Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
dfa3dfb086
commit
66805034a6
815 changed files with 4020 additions and 1138 deletions
|
|
@ -38,47 +38,64 @@ class Wootook_Database
|
|||
return self::$_connectionAliases[$connectionName];
|
||||
}
|
||||
|
||||
if ($alias = Wootook::getConfig("database/{$connectionName}/use")) {
|
||||
$connectionConfig = Wootook::getConfig("resource/database/{$connectionName}");
|
||||
if ($alias = $connectionConfig->use) {
|
||||
self::$_connectionAliases[$connectionName] = self::getConnection($alias);
|
||||
|
||||
return self::$_connectionAliases[$connectionName];
|
||||
}
|
||||
|
||||
self::$_connections[$connectionName] = self::_initConnection($connectionName);
|
||||
self::$_connections[$connectionName] = self::_initConnection($connectionName,
|
||||
$connectionConfig->engine, $connectionConfig->params, $connectionConfig->options);
|
||||
}
|
||||
|
||||
return self::$_connections[$connectionName];
|
||||
}
|
||||
|
||||
private static function _initConnection($connectionName)
|
||||
private static function _initConnection($connectionName, $engine, $params, $options = array())
|
||||
{
|
||||
$hostname = Wootook::getConfig("database/{$connectionName}/params/hostname");
|
||||
$username = Wootook::getConfig("database/{$connectionName}/params/username");
|
||||
$password = Wootook::getConfig("database/{$connectionName}/params/password");
|
||||
$database = Wootook::getConfig("database/{$connectionName}/params/database");
|
||||
if (is_array($params)) {
|
||||
$params = new Wootook_Core_Config_Node($params);
|
||||
} else if (!$params instanceof Wootook_Core_Config_Node) {
|
||||
$params = new Wootook_Core_Config_Node(array());
|
||||
}
|
||||
|
||||
if (empty($hostname) || empty($username) || empty($database)) {
|
||||
if ($options instanceof Wootook_Core_Config_Node) {
|
||||
$options = $options->toArray();
|
||||
} else if (!is_array($options)) {
|
||||
$options = array();
|
||||
}
|
||||
|
||||
$hostname = $params->hostname;
|
||||
$username = $params->username;
|
||||
$password = $params->password;
|
||||
$database = $params->database;
|
||||
|
||||
if (empty($params->hostname) || empty($params->username) || empty($params->database)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$dsn = "mysql:dbname={$database};host={$hostname}";
|
||||
if (($port = Wootook::getConfig("database/{$connectionName}/params/port")) && is_numeric($port)) {
|
||||
$dsn .= ";port={$port}";
|
||||
$dsn = "mysql:dbname={$params->database};host={$params->hostname}";
|
||||
if (is_numeric($params->port)) {
|
||||
$dsn .= ";port={$params->database}";
|
||||
}
|
||||
|
||||
$event = Wootook::dispatchEvent('database.prepare-options', array(
|
||||
'name' => $connectionName,
|
||||
'options' => array_merge(self::$options, Wootook::getConfig("database/{$connectionName}/options")->toArray())
|
||||
'options' => array_merge(self::$options, $options)
|
||||
));
|
||||
|
||||
$options = $event->getData('options');
|
||||
|
||||
$connection = new self($dsn, $username, $password, $options);
|
||||
$connection = new self($dsn, $params->username, $params->password, $options);
|
||||
$connection->_dsn = $dsn;
|
||||
$connection->_username = $username;
|
||||
$connection->_password = $password;
|
||||
|
||||
if (($prefix = Wootook::getConfig("database/{$connectionName}/table_prefix")) !== null) {
|
||||
if (defined('DEBUG')) {
|
||||
$connection->_password = $password;
|
||||
}
|
||||
|
||||
if (($prefix = Wootook::getConfig("resource/database/{$connectionName}/table_prefix")) !== null) {
|
||||
$connection->setTablePrefix($prefix);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue