FileStorage.php

Same filename in this branch
  1. 11.x core/lib/Drupal/Core/Config/FileStorage.php
  2. 11.x core/lib/Drupal/Component/PhpStorage/FileStorage.php
Same filename in other branches
  1. 9 core/modules/file/src/FileStorage.php
  2. 9 core/lib/Drupal/Core/Config/FileStorage.php
  3. 9 core/lib/Drupal/Component/PhpStorage/FileStorage.php
  4. 8.9.x core/modules/file/src/FileStorage.php
  5. 8.9.x core/lib/Drupal/Core/Config/FileStorage.php
  6. 8.9.x core/lib/Drupal/Component/PhpStorage/FileStorage.php
  7. 10 core/modules/file/src/FileStorage.php
  8. 10 core/lib/Drupal/Core/Config/FileStorage.php
  9. 10 core/lib/Drupal/Component/PhpStorage/FileStorage.php

Namespace

Drupal\file

File

core/modules/file/src/FileStorage.php

View source
<?php

namespace Drupal\file;

use Drupal\Core\Entity\Sql\SqlContentEntityStorage;

/**
 * File storage for files.
 */
class FileStorage extends SqlContentEntityStorage implements FileStorageInterface {
    
    /**
     * {@inheritdoc}
     */
    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();
    }

}

Classes

Title Deprecated Summary
FileStorage File storage for files.

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