class File

Defines the file entity class.

Plugin annotation


@Plugin(
  id = "file",
  label = @Translation("File"),
  module = "file",
  controller_class = "Drupal\file\FileStorageController",
  base_table = "file_managed",
  static_cache = FALSE,
  entity_keys = {
    "id" = "fid",
    "label" = "filename",
    "uuid" = "uuid"
  },
  view_modes = {
    "full" = {
      "label" = "File default",
      "custom_settings" = FALSE
    }
  }
)

Hierarchy

Expanded class hierarchy of File

11 files declare their use of File
comment.module in drupal/core/modules/comment/comment.module
Enables users to comment on published content.
DatabaseFileUsageBackend.php in drupal/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php
Definition of Drupal\file\FileUsage\DatabaseFileUsageBackend.
file.module in drupal/core/modules/file/file.module
Defines a "managed_file" Form API field and a "file" field for Field module.
FileUsageBase.php in drupal/core/modules/file/lib/Drupal/file/FileUsage/FileUsageBase.php
Definition of Drupal\file\FileUsage\FileUsageBase.
FileUsageInterface.php in drupal/core/modules/file/lib/Drupal/file/FileUsage/FileUsageInterface.php
Definition of Drupal\file\FileUsage\FileUsageInterface.

... See full list

27 string references to 'File'
DirectoryTest::testFileCheckDirectoryHandling in drupal/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php
Test directory handling functions.
DirectoryTest::testFileCreateNewFilepath in drupal/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php
This will take a directory and path, and find a valid filepath that is not taken by another file.
DirectoryTest::testFileDestination in drupal/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php
This will test the filepath for a destination based on passed flags and whether or not the file exists.
FileFieldDisplayTest::getInfo in drupal/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php
FileFieldPathTest::getInfo in drupal/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php

... See full list

File

drupal/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php, line 38
Definition of Drupal\file\Plugin\Core\Entity\File.

Namespace

Drupal\file\Plugin\Core\Entity
View source
class File extends Entity implements ContentEntityInterface {

  /**
   * The file ID.
   *
   * @var integer
   */
  public $fid;

  /**
   * The file UUID.
   *
   * @var string
   */
  public $uuid;

  /**
   * The file language code.
   *
   * @var string
   */
  public $langcode = LANGUAGE_NOT_SPECIFIED;

  /**
   * The uid of the user who is associated with the file.
   *
   * @var integer
   */
  public $uid;

  /**
   * Name of the file with no path components.
   *
   * This may differ from the basename of the URI if the file is renamed to
   * avoid overwriting an existing file.
   *
   * @var string
   */
  public $filename;

  /**
   * The URI to access the file (either local or remote).
   *
   * @var string
   */
  public $uri;

  /**
   * The file's MIME type.
   *
   * @var string
   */
  public $filemime;

  /**
   * The size of the file in bytes.
   *
   * @var integer
   */
  public $filesize;

  /**
   * A field indicating the status of the file.
   *
   * Two status are defined in core: temporary (0) and permanent (1).
   * Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed
   * during a cron run.
   *
   * @var integer
   */
  public $status;

  /**
   * UNIX timestamp for when the file was last saved.
   *
   * @var integer
   */
  public $timestamp;

  /**
   * Overrides Drupal\Core\Entity\Entity::id().
   */
  public function id() {
    return $this->fid;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Entity::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
Entity::$entityType protected property The entity type.
Entity::$isDefaultRevision protected property Indicates whether this is the default revision. 1
Entity::$newRevision protected property Boolean indicating whether a new revision should be created on save.
Entity::access public function Implements AccessibleInterface::access(). Overrides AccessibleInterface::access
Entity::bundle public function Implements EntityInterface::bundle(). Overrides EntityInterface::bundle 4
Entity::createDuplicate public function Implements EntityInterface::createDuplicate(). Overrides EntityInterface::createDuplicate 3
Entity::delete public function Implements EntityInterface::delete(). Overrides EntityInterface::delete
Entity::enforceIsNew public function Implements EntityInterface::enforceIsNew(). Overrides EntityInterface::enforceIsNew
Entity::entityInfo public function Implements EntityInterface::entityInfo(). Overrides EntityInterface::entityInfo
Entity::entityType public function Implements EntityInterface::entityType(). Overrides EntityInterface::entityType
Entity::get public function Implements EntityInterface::get(). Overrides ComplexDataInterface::get 2
Entity::getIterator public function Implements ComplexDataInterface::getIterator(). 1
Entity::getProperties public function Implements ComplexDataInterface::getProperties(). Overrides ComplexDataInterface::getProperties 1
Entity::getPropertyDefinition public function Implements ComplexDataInterface::getPropertyDefinition(). Overrides ComplexDataInterface::getPropertyDefinition 1
Entity::getPropertyDefinitions public function Implements ComplexDataInterface::getPropertyDefinitions(). Overrides ComplexDataInterface::getPropertyDefinitions 1
Entity::getPropertyValues public function Implements ComplexDataInterface::getPropertyValues(). Overrides ComplexDataInterface::getPropertyValues 1
Entity::getRevisionId public function Implements Drupal\Core\Entity\EntityInterface::getRevisionId(). Overrides EntityInterface::getRevisionId 3
Entity::getTranslation public function Implements TranslatableInterface::getTranslation(). Overrides TranslatableInterface::getTranslation 1
Entity::getTranslationLanguages public function Implements TranslatableInterface::getTranslationLanguages(). Overrides TranslatableInterface::getTranslationLanguages 1
Entity::isDefaultRevision public function Implements Drupal\Core\Entity\EntityInterface::isDefaultRevision(). Overrides EntityInterface::isDefaultRevision 1
Entity::isEmpty public function Implements ComplexDataInterface::isEmpty(). Overrides ComplexDataInterface::isEmpty 1
Entity::isNew public function Implements EntityInterface::isNew(). Overrides EntityInterface::isNew 1
Entity::isNewRevision public function Implements EntityInterface::isNewRevision(). Overrides EntityInterface::isNewRevision
Entity::label public function Implements EntityInterface::label(). Overrides EntityInterface::label 1
Entity::language public function Implements TranslatableInterface::language(). Overrides TranslatableInterface::language 1
Entity::save public function Implements EntityInterface::save(). Overrides EntityInterface::save 3
Entity::set public function Implements ComplexDataInterface::set(). Overrides ComplexDataInterface::set 2
Entity::setNewRevision public function Implements EntityInterface::setNewRevision(). Overrides EntityInterface::setNewRevision
Entity::setPropertyValues public function Implements ComplexDataInterface::setPropertyValues(). Overrides ComplexDataInterface::setPropertyValues 1
Entity::translations public function Returns the languages the entity is translated to.
Entity::uri public function Implements EntityInterface::uri(). Overrides EntityInterface::uri 1
Entity::uuid public function Implements EntityInterface::uuid(). Overrides EntityInterface::uuid 1
Entity::__construct public function Constructs an Entity object. 2
File::$fid public property The file ID.
File::$filemime public property The file's MIME type.
File::$filename public property Name of the file with no path components.
File::$filesize public property The size of the file in bytes.
File::$langcode public property The file language code. Overrides Entity::$langcode
File::$status public property A field indicating the status of the file.
File::$timestamp public property UNIX timestamp for when the file was last saved.
File::$uid public property The uid of the user who is associated with the file.
File::$uri public property The URI to access the file (either local or remote).
File::$uuid public property The file UUID.
File::id public function Overrides Drupal\Core\Entity\Entity::id(). Overrides Entity::id