function ServiceAuditFilesManagedNotUsed::_auditfiles_managed_not_used_get_file_data in Audit Files 8
Retrieves information about an individual file from the database.
Parameters
int $file_id: The ID of the file to prepare for display.
Return value
array The row for the table on the report, with the file's information formatted for display.
File
- src/
ServiceAuditFilesManagedNotUsed.php, line 39 - providing the service that used in 'managed not used' functionality.
Class
Namespace
Drupal\auditfilesCode
function _auditfiles_managed_not_used_get_file_data($file_id, $date_format) {
$connection = Database::getConnection();
$query = $connection
->select('file_managed', 'fm');
$query
->condition('fm.fid', $file_id);
$query
->fields('fm', [
'fid',
'uid',
'filename',
'uri',
'filemime',
'filesize',
'created',
'status',
]);
$results = $query
->execute()
->fetchAll();
$file = $results[0];
return [
'fid' => $file->fid,
'uid' => $file->uid,
'filename' => $file->filename,
'uri' => $file->uri,
'path' => drupal_realpath($file->uri),
'filemime' => $file->filemime,
'filesize' => number_format($file->filesize),
'datetime' => \Drupal::service('date.formatter')
->format($file->created, $date_format),
'status' => ($file->status = 1) ? 'Permanent' : 'Temporary',
];
}