public function ServiceAuditFilesNotOnServer::auditfilesNotOnServerGetFileData in Audit Files 8.2
Same name and namespace in other branches
- 8.3 src/ServiceAuditFilesNotOnServer.php \Drupal\auditfiles\ServiceAuditFilesNotOnServer::auditfilesNotOnServerGetFileData()
- 4.x src/ServiceAuditFilesNotOnServer.php \Drupal\auditfiles\ServiceAuditFilesNotOnServer::auditfilesNotOnServerGetFileData()
Retrieves information about an individual file from the database.
Parameters
int $file_id: The ID of the file to prepare for display.
string $date_format: The Date format to prepair for display.
Return value
array The row for the table on the report, with the file's information formatted for display.
File
- src/
ServiceAuditFilesNotOnServer.php, line 97
Class
- ServiceAuditFilesNotOnServer
- Providing the service that used in not in database functionality.
Namespace
Drupal\auditfilesCode
public function auditfilesNotOnServerGetFileData($file_id, $date_format) {
$connection = $this->connection;
$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' => $this->fileSystem
->realpath($file->uri),
'filemime' => $file->filemime,
'filesize' => number_format($file->filesize),
'datetime' => $this->dateFormatter
->format($file->created, $date_format),
'status' => $file->status == 1 ? 'Permanent' : 'Temporary',
];
}