Back to Captcha class

Method _load

private void
_load
(array $options = array())
Load the Captcha plugin.
Parameters
  • array $options Associative array of options.
Returns
  • void
Since
  • 2.5
-
  • \RuntimeException
Class: Captcha
Project: Joomla

Method _load - Source code

/**
 * 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);
}