public function ServiceAuditFilesNotOnServer::auditfilesNotOnServerGetFileList in Audit Files 8.3
Same name and namespace in other branches
- 8.2 src/ServiceAuditFilesNotOnServer.php \Drupal\auditfiles\ServiceAuditFilesNotOnServer::auditfilesNotOnServerGetFileList()
- 4.x src/ServiceAuditFilesNotOnServer.php \Drupal\auditfiles\ServiceAuditFilesNotOnServer::auditfilesNotOnServerGetFileList()
Retrieves the file IDs to operate on.
Return value
array The file IDs.
File
- src/
ServiceAuditFilesNotOnServer.php, line 71
Class
- ServiceAuditFilesNotOnServer
- Providing the service that used in not in database functionality.
Namespace
Drupal\auditfilesCode
public function auditfilesNotOnServerGetFileList() {
$config = $this->configFactory
->get('auditfiles.settings');
$file_ids = [];
$maximum_records = $config
->get('auditfiles_report_options_maximum_records');
$connection = $this->connection;
$query = $connection
->select('file_managed', 'fm');
$query
->orderBy('changed', 'DESC');
$query
->range(0, $maximum_records);
$query
->fields('fm', [
'fid',
'uri',
]);
$results = $query
->execute()
->fetchAll();
foreach ($results as $result) {
$target = $this->fileSystem
->realpath($result->uri);
if (!file_exists($target)) {
$file_ids[] = $result->fid;
}
}
return $file_ids;
}