You are here

function ServiceAuditFilesNotInDatabase::_auditfiles_not_in_database_batch_delete_process_file in Audit Files 8

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 426
providing the service that used in not in database functionality.

Class

ServiceAuditFilesNotInDatabase

Namespace

Drupal\auditfiles

Code

function _auditfiles_not_in_database_batch_delete_process_file($filename) {
  $config = \Drupal::config('auditfiles_config.settings');
  $file_system_stream = $config
    ->get('auditfiles_file_system_path') ? $config
    ->get('auditfiles_file_system_path') : 'public';
  $real_files_path = drupal_realpath($file_system_stream . '://');
  if (file_unmanaged_delete($real_files_path . DIRECTORY_SEPARATOR . $filename)) {
    drupal_set_message(t('Sucessfully deleted %file from the server.', [
      '%file' => $filename,
    ]));
  }
  else {
    drupal_set_message(t('Failed to delete %file from the server.', [
      '%file' => $filename,
    ]));
  }
}