You are here

public function ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseGetReportsFiles in Audit Files 8.3

Same name and namespace in other branches
  1. 8.2 src/ServiceAuditFilesNotInDatabase.php \Drupal\auditfiles\ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseGetReportsFiles()
  2. 4.x src/ServiceAuditFilesNotInDatabase.php \Drupal\auditfiles\ServiceAuditFilesNotInDatabase::auditfilesNotInDatabaseGetReportsFiles()

Get the files that are not in database.

File

src/ServiceAuditFilesNotInDatabase.php, line 123

Class

ServiceAuditFilesNotInDatabase
Define all methods that are used on Files not in database functionality.

Namespace

Drupal\auditfiles

Code

public function auditfilesNotInDatabaseGetReportsFiles() {
  $config = $this->configFactory
    ->get('auditfiles.settings');
  $exclusions = $this
    ->auditFilesGetExclusions();
  $report_files = [];
  $reported_files = [];
  $this
    ->auditfilesNotInDatabaseGetFilesForReport('', $report_files, $exclusions);
  if (!empty($report_files)) {

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

    // The full file system path to the Drupal root directory.
    $real_files_path = $this->fileSystem
      ->realpath($file_system_stream . '://');

    // Get the chosen date format for displaying the file dates with.
    $date_format = $config
      ->get('auditfiles_report_options_date_format');
    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'];
      }

      // If the file is not in the database, add to the list for displaying.
      if (!$this
        ->auditfilesNotInDatabaseIsFileInDatabase($file_to_check)) {

        // Gets the file's information (size, date, etc.) and assempbles the.
        // array for the table.
        $reported_files += $this
          ->auditfilesNotInDatabaseFormatRowData($report_file, $real_files_path, $date_format);
      }
    }
  }
  return $reported_files;
}