You are here

function ServiceAuditFilesNotInDatabase::_auditfiles_not_in_database_get_reports_files in Audit Files 8

Get the files that are not in database.

File

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

Class

ServiceAuditFilesNotInDatabase

Namespace

Drupal\auditfiles

Code

function _auditfiles_not_in_database_get_reports_files() {
  $config = \Drupal::config('auditfiles_config.settings');
  $report_files = [];
  $reported_files = [];
  $this
    ->_auditfiles_not_in_database_get_files_for_report('', $report_files);
  if (!empty($report_files)) {

    // Get the static paths necessary for processing the files.
    $file_system_stream = $config
      ->get('auditfiles_file_system_path') ? $config
      ->get('auditfiles_file_system_path') : 'public';

    // The full file system path to the Drupal root directory.
    $real_files_path = drupal_realpath($file_system_stream . '://');

    // Get the chosen date format for displaying the file dates with.
    $date_format = $config
      ->get('auditfiles_report_options_date_format') ? $config
      ->get('auditfiles_report_options_date_format') : 'long';
    foreach ($report_files as $report_file) {

      // Check to see if the file is in the database.
      if (empty($report_file['path_from_files_root'])) {
        $file_to_check = $report_file['file_name'];
      }
      else {
        $file_to_check = $report_file['path_from_files_root'] . DIRECTORY_SEPARATOR . $report_file['file_name'];
      }
      $file_in_database = $this
        ->_auditfiles_not_in_database_is_file_in_database($file_to_check);

      // If the file is not in the database, add it to the list for displaying.
      if (!$file_in_database) {

        // Gets the file's information (size, date, etc.) and assempbles the

        //array for the table.
        $reported_files += $this
          ->_auditfiles_not_in_database_format_row_data($report_file, $real_files_path, $date_format);
      }
    }
  }
  return $reported_files;
}