You are here

protected function DisplayFileList::buildStatistics in Filebrowser 8.2

Same name and namespace in other branches
  1. 3.x src/File/DisplayFileList.php \Drupal\filebrowser\File\DisplayFileList::buildStatistics()
1 call to DisplayFileList::buildStatistics()
DisplayFileList::processServerFileList in src/File/DisplayFileList.php

File

src/File/DisplayFileList.php, line 397

Class

DisplayFileList
Class FileDisplayList @package Drupal\filebrowser This class holds the list of files to be displayed on the filebrowser node. These files are retrieved from the filesystem and filtered for user and node access. The array produced by this class…

Namespace

Drupal\filebrowser\File

Code

protected function buildStatistics($list) {

  //debug(array_keys($list));
  $files = 0;
  $folders = 0;
  $total_size = 0;
  foreach ($list as $key => $item) {
    if (in_array($key, [
      '.',
      '..',
    ])) {
    }
    else {
      if ($item->fileData->type == 'file') {
        $files++;
        $total_size = $total_size + $item->fileData->size;
      }
      else {
        $folders++;
      }
    }
  }
  return [
    'files' => $files,
    'folders' => $folders,
    'size' => $total_size,
  ];
}