You are here

function clamav_requirements in ClamAV 8

Same name and namespace in other branches
  1. 6 clamav.install \clamav_requirements()
  2. 7 clamav.install \clamav_requirements()
  3. 2.x clamav.install \clamav_requirements()

Implements hook_requirements().

File

./clamav.install, line 15
Install, update and uninstall functions for the clamav module.

Code

function clamav_requirements($phase) {
  $requirements = array();

  // Report Drupal version
  if ($phase == 'runtime') {
    $config = new Config();
    switch ($config
      ->scan_mode()) {
      case Config::MODE_DAEMON:
        $scanner = new Scanner\DaemonTCPIP($config);
        break;
      case Config::MODE_EXECUTABLE:
        $scanner = new Scanner\Executable($config);
        break;
      case Config::MODE_UNIX_SOCKET:
        $scanner = new Scanner\DaemonUnixSocket($config);
        break;
    }
    if ($version = $scanner
      ->version()) {
      $requirements['clamav'] = array(
        'title' => t('ClamAV version'),
        'value' => $scanner
          ->version(),
        'severity' => REQUIREMENT_INFO,
      );
    }
    else {
      $requirements['clamav'] = array(
        'title' => t('ClamAV version'),
        'value' => t('Unable to connect to ClamAV service.'),
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}