public function ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseBatchDeleteProcessFile in Audit Files 4.x
Same name and namespace in other branches
- 8.3 src/ServiceAuditFilesNotInDatabase.php \Drupal\auditfiles\ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseBatchDeleteProcessFile()
- 8.2 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 522
Class
- ServiceAuditFilesNotInDatabase
- Define all methods that are used on Files not in database functionality.
Namespace
Drupal\auditfilesCode
public function auditfilesNotInDatabaseBatchDeleteProcessFile($filename) {
$config = $this->configFactory
->get('auditfiles.settings');
$file_system_stream = $config
->get('auditfiles_file_system_path') ? $config
->get('auditfiles_file_system_path') : 'public';
$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,
]));
}
}