You are here

function ldap_servers_requirements in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.install \ldap_servers_requirements()
  2. 8.3 ldap_servers/ldap_servers.install \ldap_servers_requirements()
  3. 7.2 ldap_servers/ldap_servers.install \ldap_servers_requirements()
  4. 7 ldap_servers/ldap_servers.install \ldap_servers_requirements()

Implements hook_requirements().

File

ldap_servers/ldap_servers.install, line 13

Code

function ldap_servers_requirements($phase) : array {
  $requirements = [];
  if (version_compare(phpversion(), '7.2.0') < 0) {
    $requirements['php_ldap_version'] = [
      'title' => t('PHP Version for LDAP'),
      'description' => t('Your PHP installation is too old for the LDAP module. Please upgrade to at least 7.2.'),
      'severity' => REQUIREMENT_ERROR,
      'value' => phpversion(),
    ];
  }
  if (extension_loaded('ldap')) {
    $requirements['ldap_extension_loaded'] = [
      'title' => t('PHP LDAP extension'),
      'severity' => REQUIREMENT_OK,
      'value' => t('Available'),
    ];
  }
  else {
    $requirements['ldap_extension_loaded'] = [
      'title' => t('PHP LDAP extension'),
      'severity' => REQUIREMENT_ERROR,
      'value' => t('Missing'),
      'description' => t('The LDAP extension of PHP is not available. Please consult your distribution to discover how to install it.'),
    ];
  }
  if (!class_exists('Symfony\\Component\\Ldap\\Ldap')) {
    $requirements['ldap_library_present'] = [
      'title' => t('LDAP library'),
      'severity' => REQUIREMENT_ERROR,
      'value' => t('Missing \\Symfony\\Component\\Ldap\\Ldap'),
      'description' => t('You are missing a critical dependency, you should install via Composer which provides it.'),
    ];
  }
  return $requirements;
}