You are here

class Statistics in Filebrowser 8.2

Same name and namespace in other branches
  1. 3.x src/Statistics.php \Drupal\filebrowser\Statistics

Hierarchy

Expanded class hierarchy of Statistics

File

src/Statistics.php, line 5

Namespace

Drupal\filebrowser
View source
class Statistics {

  /**
   * @var array $listing Array containing the list of files to be displayed
   */
  protected $statistics;

  /**
   * Statistics constructor.
   * @param array $listing
   */
  public function __construct($listing) {
    $stats = $listing['data']['stats'];
    if ($stats['folders'] > 0) {
      $this->statistics['folders'] = \Drupal::translation()
        ->formatPlural($stats['folders'], '1 folder', '@count folders');
    }
    if ($stats['files'] > 0) {
      $this->statistics['files'] = \Drupal::translation()
        ->formatPlural($stats['files'], '1 file', '@count files');
      $this->statistics['size'] = format_size($stats['size']);
    }
  }
  public function get() {
    return [
      '#theme' => 'statistics',
      '#statistics' => $this->statistics,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Statistics::$statistics protected property
Statistics::get public function
Statistics::__construct public function Statistics constructor.