You are here

public static function Scanner::isSchemeScannable in ClamAV 2.x

Same name and namespace in other branches
  1. 8 src/Scanner.php \Drupal\clamav\Scanner::isSchemeScannable()

Determine whether files of a given scheme should be scanned.

Parameters

string $scheme: The machine name of a stream-wrapper scheme, such as "public", or "youtube".

Return value

boolean TRUE if the scheme should be scanned.

1 call to Scanner::isSchemeScannable()
Scanner::isScannable in src/Scanner.php
Check whether a specific file should be scanned by ClamAV.

File

src/Scanner.php, line 211

Class

Scanner
Service class for the ClamAV scanner instance.

Namespace

Drupal\clamav

Code

public static function isSchemeScannable($scheme) {
  if (empty($scheme)) {
    return TRUE;
  }

  // By default all local schemes should be scannable.
  $mgr = \Drupal::service('stream_wrapper_manager');
  $local_schemes = array_keys($mgr
    ->getWrappers(StreamWrapperInterface::LOCAL));
  $scheme_is_local = in_array($scheme, $local_schemes);

  // The default can be overridden per scheme.
  $config = \Drupal::config('clamav.settings');
  $overridden_schemes = $config
    ->get('overridden_schemes');
  $scheme_is_overridden = in_array($scheme, $overridden_schemes);
  return $scheme_is_local xor $scheme_is_overridden;
}