function tfa_get_plugin in Two-factor Authentication (TFA) 7.2
Get or create a TFA plugin object.
Parameters
string $plugin_name: Plugin name.
array $context: TFA context.
Return value
TfaBasePlugin|false TFA plugin or FALSE on error.
1 call to tfa_get_plugin()
- tfa_get_process in ./
tfa.module - Get Tfa object in the account's current context.
File
- ./
tfa.module, line 208 - Two-factor authentication for Drupal.
Code
function tfa_get_plugin($plugin_name, array $context) {
$api = module_invoke_all('tfa_api');
// Call plugin callback.
if (isset($api[$plugin_name]['callback'])) {
$function = $api[$plugin_name]['callback'];
return $function($context);
}
// Or (plugin_name)_create.
$function = $plugin_name . '_create';
if (function_exists($function)) {
return $function($context);
}
// Or if class is defined instantiate it.
if (isset($api[$plugin_name]['class'])) {
$class = $api[$plugin_name]['class'];
return new $class($context);
}
return FALSE;
}