function FileStorage::spaceUsed

Same name in other branches
  1. 9 core/modules/file/src/FileStorage.php \Drupal\file\FileStorage::spaceUsed()
  2. 8.9.x core/modules/file/src/FileStorage.php \Drupal\file\FileStorage::spaceUsed()
  3. 10 core/modules/file/src/FileStorage.php \Drupal\file\FileStorage::spaceUsed()

Overrides FileStorageInterface::spaceUsed

File

core/modules/file/src/FileStorage.php, line 15

Class

FileStorage
File storage for files.

Namespace

Drupal\file

Code

public function spaceUsed($uid = NULL, $status = FileInterface::STATUS_PERMANENT) {
    $query = $this->database
        ->select($this->entityType
        ->getBaseTable(), 'f')
        ->condition('f.status', $status);
    $query->addExpression('SUM([f].[filesize])', 'filesize');
    if (isset($uid)) {
        $query->condition('f.uid', $uid);
    }
    return $query->execute()
        ->fetchField();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.