Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. File.php

function File::preSave

Overrides ContentEntityBase::preSave

File

core/modules/file/src/Entity/File.php, line 184

Class

File
Defines the file entity class.

Namespace

Drupal\file\Entity

Code

public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    // The file itself might not exist or be available right now.
    $uri = $this->getFileUri();
    $size = @filesize($uri);
    // Set size unless there was an error.
    if ($size !== FALSE) {
        $this->setSize($size);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal