/**
* Load the Captcha plugin.
*
* @param array $options Associative array of options.
*
* @return void
*
* @since 2.5
* @throws \RuntimeException
*/
private function _load(array $options = array())
{
// Build the path to the needed captcha plugin
$name = InputFilter::getInstance()->clean($this->name, 'cmd');
$path = JPATH_PLUGINS . '/captcha/' . $name . '/' . $name . '.php';
if (!is_file($path)) {
throw new \RuntimeException(Text::sprintf('JLIB_CAPTCHA_ERROR_PLUGIN_NOT_FOUND', $name));
}
// Require plugin file
require_once $path;
// Get the plugin
$plugin = PluginHelper::getPlugin('captcha', $this->name);
if (!$plugin) {
throw new \RuntimeException(Text::sprintf('JLIB_CAPTCHA_ERROR_PLUGIN_NOT_FOUND', $name));
}
// Check for already loaded params
if (!$plugin->params instanceof Registry) {
$params = new Registry($plugin->params);
$plugin->params = $params;
}
// Build captcha plugin classname
$name = 'PlgCaptcha' . $this->name;
$dispatcher = $this->getDispatcher();
$this->captcha = new $name($dispatcher, (array) $plugin, $options);
}