Back to Installer class

Method loadAdapter

public \Joomla\CMS\Installer\InstallerAdapter
loadAdapter
(mixed $adapter, mixed $options = array())
Method to load an adapter instance
Parameters
  • string $adapter Adapter name
  • array $options Adapter options
Returns
  • \Joomla\CMS\Installer\InstallerAdapter
Since
  • 3.4
-
  • \InvalidArgumentException
Class: Installer
Project: Joomla

Method loadAdapter - Source code

/**
 * Method to load an adapter instance
 *
 * @param   string  $adapter  Adapter name
 * @param   array   $options  Adapter options
 *
 * @return  InstallerAdapter
 *
 * @since   3.4
 * @throws  \InvalidArgumentException
 */
public function loadAdapter($adapter, $options = array())
{
    $class = rtrim($this->_classprefix, '\\') . '\\' . ucfirst($adapter) . 'Adapter';
    if (!class_exists($class)) {
        // Not namespaced
        $class = $this->_classprefix . ucfirst($adapter);
    }
    if (!class_exists($class)) {
        throw new \InvalidArgumentException(sprintf('The %s install adapter does not exist.', $adapter));
    }
    // Ensure the adapter type is part of the options array
    $options['type'] = $adapter;
    // Check for a possible service from the container otherwise manually instantiate the class
    if (Factory::getContainer()->has($class)) {
        return Factory::getContainer()->get($class);
    }
    return new $class($this, $this->getDbo(), $options);
}