Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 41 additions & 39 deletions libraries/joomla/base/adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,68 +86,70 @@ public function getDBO()
}

/**
* Set an adapter by name
* Return an adapter.
*
* @param string $name Adapter name
* @param object &$adapter Adapter object
* @param array $options Adapter options
* @param string $name Name of adapter to return
* @param array $options Adapter options
*
* @return boolean True if successful
* @return object Adapter of type 'name' or false
*
* @since 11.1
*/
public function setAdapter($name, &$adapter = null, $options = array())
public function getAdapter($name, $options = array())
{
if (!is_object($adapter))
if (array_key_exists($name, $this->_adapters))
{
$fullpath = $this->_basepath . '/' . $this->_adapterfolder . '/' . strtolower($name) . '.php';

if (!file_exists($fullpath))
{
return false;
}

// Try to load the adapter object
require_once $fullpath;

$class = $this->_classprefix . ucfirst($name);

if (!class_exists($class))
{
return false;
}

$adapter = new $class($this, $this->_db, $options);
return $this->_adapters[$name];
}

$this->_adapters[$name] = &$adapter;
if ($this->setAdapter($name, $options))
{
return $this->_adapters[$name];
}

return true;
return false;
}

/**
* Return an adapter.
* Set an adapter by name
*
* @param string $name Name of adapter to return
* @param array $options Adapter options
* @param string $name Adapter name
* @param object &$adapter Adapter object
* @param array $options Adapter options
*
* @return object Adapter of type 'name' or false
* @return boolean True if successful
*
* @since 11.1
*/
public function getAdapter($name, $options = array())
public function setAdapter($name, &$adapter = null, $options = array())
{
if (!array_key_exists($name, $this->_adapters))
if (is_object($adapter))
{
if (!$this->setAdapter($name, $options))
{
$false = false;
$this->_adapters[$name] = &$adapter;

return $false;
}
return true;
}

$fullpath = $this->_basepath . '/' . $this->_adapterfolder . '/' . strtolower($name) . '.php';

if (!file_exists($fullpath))
{
return false;
}

// Try to load the adapter object
require_once $fullpath;

$class = $this->_classprefix . ucfirst($name);

if (!class_exists($class))
{
return false;
}

return $this->_adapters[$name];
$this->_adapters[$name] = new $class($this, $this->_db, $options);

return true;
}

/**
Expand Down