New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for composer dependencies during module installation #7

Closed
talhaparacha opened this Issue Aug 6, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@talhaparacha
Copy link

talhaparacha commented Aug 6, 2016

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.

@talhaparacha

This comment has been minimized.

Copy link
Author

talhaparacha commented Aug 6, 2016

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;
}
@therealssj

This comment has been minimized.

Copy link
Owner

therealssj commented Aug 11, 2016

marked for next commit.

@therealssj therealssj closed this Aug 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment