public static getDriverConfig ( mixed $backend, string $type = 'sql' ) : array | ||
$backend | mixed | The backend system (e.g. 'prefs', 'categories', 'contacts') being used. The used configuration array will be $conf[$backend]. If an array gets passed, it will be $conf[$key1][$key2]. |
$type | string | The type of driver. If null, will not merge with base config. |
Результат | array | The connection parameters. |
public static function getDriverConfig($backend, $type = 'sql')
{
global $conf;
if (!is_null($type)) {
$type = Horde_String::lower($type);
}
if (is_array($backend)) {
$c = Horde_Array::getElement($conf, $backend);
} elseif (isset($conf[$backend])) {
$c = $conf[$backend];
} else {
$c = null;
}
if (!is_null($c) && isset($c['params'])) {
$c['params']['umask'] = $conf['umask'];
return !is_null($type) && isset($conf[$type]) ? array_merge($conf[$type], $c['params']) : $c['params'];
}
return !is_null($type) && isset($conf[$type]) ? $conf[$type] : array();
}
/** * Return the Agora_Driver:: instance. * * @param string $scope Instance scope * @param int $forum_id Forum to link to * * @return Agora_Driver The singleton instance. * @throws Agora_Exception */ public function create($scope = 'agora', $forum_id = 0) { if (!isset($this->_instances[$scope])) { $driver = $GLOBALS['conf']['threads']['split'] ? 'SplitSql' : 'Sql'; $params = Horde::getDriverConfig('sql'); $class = 'Agora_Driver_' . $driver; if (!class_exists($class)) { throw new Agora_Exception(sprintf('Unable to load the definition of %s.', $class)); } $params = array('db' => $this->_injector->getInstance('Horde_Db_Adapter'), 'charset' => $params['charset']); $driver = new $class($scope, $params); $this->_instances[$scope] = $driver; } if ($forum_id) { /* Check if there was a valid forum object to get. */ try { $forum = $this->_instances[$scope]->getForum($forum_id); } catch (Horde_Exception $e) { throw new Agora_Exception($e->getMessage()); } /* Set current forum id and forum data */ $this->_instances[$scope]->_forum = $forum; $this->_instances[$scope]->_forum_id = (int) $forum_id; } return $this->_instances[$scope]; }