You are here

public static function AuditFilesBatchProcess::auditfilesMakePreg in Audit Files 8.2

Escapes any possible regular expression characters in the specified string.

Parameters

string $element: The string to escape.

mixed $key: The key or index for the array item passed into $element.

bool $makefilepath: Set to TRUE to change elements to file paths at the same time.

File

src/AuditFilesBatchProcess.php, line 75

Class

AuditFilesBatchProcess
Process batch files.

Namespace

Drupal\auditfiles

Code

public static function auditfilesMakePreg(&$element, $key = '', $makefilepath = FALSE) {
  if ($makefilepath) {
    $realpath = \Drupal::service('file_system')
      ->realpath(file_build_uri($element));
    if ($realpath) {
      $element = $realpath;
    }
  }
  $element = preg_quote($element);
}