/**
* Set an adapter by name
*
* @param string $name Adapter name
* @param object $adapter Adapter object
* @param array $options Adapter options
*
* @return boolean True if successful
*
* @since 1.6
*/
public function setAdapter($name, &$adapter = null, $options = array())
{
if (is_object($adapter)) {
$this->_adapters[$name] =& $adapter;
return true;
}
$class = rtrim($this->_classprefix, '\\') . '\\' . ucfirst($name);
if (class_exists($class)) {
$this->_adapters[$name] = new $class($this, $this->_db, $options);
return true;
}
$class = rtrim($this->_classprefix, '\\') . '\\' . ucfirst($name) . 'Adapter';
if (class_exists($class)) {
$this->_adapters[$name] = new $class($this, $this->_db, $options);
return true;
}
$fullpath = $this->_basepath . '/' . $this->_adapterfolder . '/' . strtolower($name) . '.php';
if (!is_file($fullpath)) {
return false;
}
// Try to load the adapter object
$class = $this->_classprefix . ucfirst($name);
\JLoader::register($class, $fullpath);
if (!class_exists($class)) {
return false;
}
$this->_adapters[$name] = new $class($this, $this->_db, $options);
return true;
}