You are here

public function ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseBatchDeleteProcessFile in Audit Files 8.3

Same name and namespace in other branches
  1. 8.2 src/ServiceAuditFilesNotInDatabase.php \Drupal\auditfiles\ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseBatchDeleteProcessFile()
  2. 4.x src/ServiceAuditFilesNotInDatabase.php \Drupal\auditfiles\ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseBatchDeleteProcessFile()

Deletes the specified file from the server.

Parameters

string $filename: The full pathname of the file to delete from the server.

File

src/ServiceAuditFilesNotInDatabase.php, line 524

Class

ServiceAuditFilesNotInDatabase
Define all methods that are used on Files not in database functionality.

Namespace

Drupal\auditfiles

Code

public function auditfilesNotInDatabaseBatchDeleteProcessFile($filename) {
  $config = $this->configFactory
    ->get('auditfiles.settings');
  $file_system_stream = $config
    ->get('auditfiles_file_system_path');
  $real_files_path = $this->fileSystem
    ->realpath($file_system_stream . '://');
  if ($this->fileSystem
    ->delete($real_files_path . DIRECTORY_SEPARATOR . $filename)) {
    $this
      ->messenger()
      ->addStatus($this->stringTranslation
      ->translate('Sucessfully deleted %file from the server.', [
      '%file' => $filename,
    ]));
  }
  else {
    $this
      ->messenger()
      ->addStatus($this->stringTranslation
      ->translate('Failed to delete %file from the server.', [
      '%file' => $filename,
    ]));
  }
}