FileStorage.php

Same filename in this branch
  1. 8.9.x core/lib/Drupal/Core/Config/FileStorage.php
  2. 8.9.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. 10 core/modules/file/src/FileStorage.php
  5. 10 core/lib/Drupal/Core/Config/FileStorage.php
  6. 10 core/lib/Drupal/Component/PhpStorage/FileStorage.php
  7. 11.x core/modules/file/src/FileStorage.php
  8. 11.x core/lib/Drupal/Core/Config/FileStorage.php
  9. 11.x 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 = FILE_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.