You are here

Statistics.php in Filebrowser 3.x

Same filename and directory in other branches
  1. 8.2 src/Statistics.php

Namespace

Drupal\filebrowser

File

src/Statistics.php
View source
<?php

namespace Drupal\filebrowser;

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,
    ];
  }

}

Classes

Namesort descending Description
Statistics