You are here

function ServiceAuditFilesNotInDatabase::_auditfiles_not_in_database_format_row_data in Audit Files 8

Add files to record to display in reports.

1 call to ServiceAuditFilesNotInDatabase::_auditfiles_not_in_database_format_row_data()
ServiceAuditFilesNotInDatabase::_auditfiles_not_in_database_get_reports_files in src/ServiceAuditFilesNotInDatabase.php
Get the files that are not in database.

File

src/ServiceAuditFilesNotInDatabase.php, line 109
providing the service that used in not in database functionality.

Class

ServiceAuditFilesNotInDatabase

Namespace

Drupal\auditfiles

Code

function _auditfiles_not_in_database_format_row_data($file, $real_path, $date_format) {
  $filename = $file['file_name'];
  $filepath = $file['path_from_files_root'];
  if (empty($filepath)) {
    $filepathname = $filename;
  }
  else {
    $filepathname = $filepath . DIRECTORY_SEPARATOR . $filename;
  }
  $real_filepathname = $real_path . DIRECTORY_SEPARATOR . $filepathname;
  $filemime = \Drupal::service('file.mime_type.guesser')
    ->guess($real_filepathname);
  $filesize = number_format(filesize($real_filepathname));
  if (!empty($date_format)) {
    $filemodtime = format_date(filemtime($real_filepathname), $date_format);
  }

  // Format the data for the table row.
  $row_data[$filepathname] = [
    'filepathname' => empty($filepathname) ? '' : $filepathname,
    'filemime' => empty($filemime) ? '' : $filemime,
    'filesize' => !isset($filesize) ? '' : $filesize,
    'filemodtime' => empty($filemodtime) ? '' : $filemodtime,
    'filename' => empty($filename) ? '' : $filename,
  ];
  return $row_data;
}