Closed paraacha closed 8 years ago
The following code, in tfa.install, would take care of the issue:
/**
* Implements hook_requirements().
*/
function tfa_requirements($phase) {
$requirements = array();
$requirements['tfa'] = array(
'title' => t('Two-factor Authentication (TFA)'),
);
if (class_exists('\Otp\Otp')) {
$requirements['tfa']['severity'] = REQUIREMENT_OK;
}
else {
$requirements['tfa']['severity'] = REQUIREMENT_ERROR;
$requirements['tfa']['description'] = t("Please install the 'christian-riesen/otp' library via composer. See the module README for instructions.");
}
return $requirements;
}
marked for next commit.
As specified in the composer.json file, the module depends on the PHP package christian-riesen/otp for its working. A user needs to install this package before installing the module.
So the logical thing is to stop the module from being installed if this dependency is not met. A simple hook_requirements() implementation will do the job.