FileStorage.php in Drupal 9
File
core/modules/file/src/FileStorage.php
View source
<?php
namespace Drupal\file;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
class FileStorage extends SqlContentEntityStorage implements FileStorageInterface {
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();
}
}