You are here

clamav.install in ClamAV 2.x

Same filename and directory in other branches
  1. 8 clamav.install
  2. 6 clamav.install
  3. 7 clamav.install

Install, update and uninstall functions for the clamav module.

File

clamav.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the clamav module.
 */
use Drupal\clamav\Config;
use Drupal\clamav\Scanner;

/**
 * Implements hook_requirements().
 */
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;
}

// @TODO: how to port D7 config to D8?

Functions

Namesort descending Description
clamav_requirements Implements hook_requirements().