Drupal 8  8.0.2
File Class Reference
Inheritance diagram for File:

Public Member Functions

 getFilename ()
 
 setFilename ($filename)
 
 getFileUri ()
 
 setFileUri ($uri)
 
 url ($rel= 'canonical', $options=array())
 
 getMimeType ()
 
 setMimeType ($mime)
 
 getSize ()
 
 setSize ($size)
 
 getCreatedTime ()
 
 getOwner ()
 
 getOwnerId ()
 
 setOwnerId ($uid)
 
 setOwner (UserInterface $account)
 
 isPermanent ()
 
 isTemporary ()
 
 setPermanent ()
 
 setTemporary ()
 
 preSave (EntityStorageInterface $storage)
 
- Public Member Functions inherited from ContentEntityBase
 __construct (array $values, $entity_type, $bundle=FALSE, $translations=array())
 
 postCreate (EntityStorageInterface $storage)
 
 setNewRevision ($value=TRUE)
 
 isNewRevision ()
 
 isDefaultRevision ($new_value=NULL)
 
 isRevisionTranslationAffected ()
 
 setRevisionTranslationAffected ($affected)
 
 isDefaultTranslation ()
 
 getRevisionId ()
 
 isTranslatable ()
 
 preSave (EntityStorageInterface $storage)
 
 preSaveRevision (EntityStorageInterface $storage,\stdClass $record)
 
 validate ()
 
 isValidationRequired ()
 
 setValidationRequired ($required)
 
 __sleep ()
 
 id ()
 
 bundle ()
 
 uuid ()
 
 hasField ($field_name)
 
 get ($field_name)
 
 set ($name, $value, $notify=TRUE)
 
 getFields ($include_computed=TRUE)
 
 getTranslatableFields ($include_computed=TRUE)
 
 getIterator ()
 
 getFieldDefinition ($name)
 
 getFieldDefinitions ()
 
 toArray ()
 
 access ($operation, AccountInterface $account=NULL, $return_as_object=FALSE)
 
 language ()
 
 onChange ($name)
 
 getTranslation ($langcode)
 
 getUntranslated ()
 
 hasTranslation ($langcode)
 
 isNewTranslation ()
 
 removeTranslation ($langcode)
 
 getTranslationLanguages ($include_default=TRUE)
 
 updateOriginalValues ()
 
__get ($name)
 
 __set ($name, $value)
 
 __isset ($name)
 
 __unset ($name)
 
 createDuplicate ()
 
 __clone ()
 
 label ()
 
 referencedEntities ()
 
- Public Member Functions inherited from Entity
 __construct (array $values, $entity_type)
 
 id ()
 
 uuid ()
 
 isNew ()
 
 enforceIsNew ($value=TRUE)
 
 getEntityTypeId ()
 
 bundle ()
 
 label ()
 
 urlInfo ($rel= 'canonical', array $options=[])
 
 toUrl ($rel= 'canonical', array $options=[])
 
 hasLinkTemplate ($rel)
 
 link ($text=NULL, $rel= 'canonical', array $options=[])
 
 toLink ($text=NULL, $rel= 'canonical', array $options=[])
 
 url ($rel= 'canonical', $options=array())
 
 uriRelationships ()
 
 access ($operation, AccountInterface $account=NULL, $return_as_object=FALSE)
 
 language ()
 
 save ()
 
 delete ()
 
 createDuplicate ()
 
 getEntityType ()
 
 preSave (EntityStorageInterface $storage)
 
 postSave (EntityStorageInterface $storage, $update=TRUE)
 
 postCreate (EntityStorageInterface $storage)
 
 referencedEntities ()
 
 getCacheContexts ()
 
 getCacheTagsToInvalidate ()
 
 getCacheTags ()
 
 getCacheMaxAge ()
 
 getOriginalId ()
 
 setOriginalId ($id)
 
 toArray ()
 
 getTypedData ()
 
 __sleep ()
 
 getConfigDependencyKey ()
 
 getConfigDependencyName ()
 
 getConfigTarget ()
 
- Public Member Functions inherited from RefinableCacheableDependencyInterface
 addCacheContexts (array $cache_contexts)
 
 addCacheTags (array $cache_tags)
 
 mergeCacheMaxAge ($max_age)
 
 addCacheableDependency ($other_object)
 
- Public Member Functions inherited from ContentEntityInterface
 hasTranslationChanges ()
 
- Public Member Functions inherited from TranslatableInterface
 addTranslation ($langcode, array $values=array())
 
- Public Member Functions inherited from EntityChangedInterface
 getChangedTime ()
 
 setChangedTime ($timestamp)
 
 getChangedTimeAcrossTranslations ()
 
- Public Member Functions inherited from EntityOwnerInterface
 setOwner (UserInterface $account)
 

Static Public Member Functions

static preCreate (EntityStorageInterface $storage, array &$values)
 
static preDelete (EntityStorageInterface $storage, array $entities)
 
static baseFieldDefinitions (EntityTypeInterface $entity_type)
 
- Static Public Member Functions inherited from ContentEntityBase
static bundleFieldDefinitions (EntityTypeInterface $entity_type, $bundle, array $base_field_definitions)
 
- Static Public Member Functions inherited from Entity
static preCreate (EntityStorageInterface $storage, array &$values)
 
static preDelete (EntityStorageInterface $storage, array $entities)
 
static postDelete (EntityStorageInterface $storage, array $entities)
 
static postLoad (EntityStorageInterface $storage, array &$entities)
 
static load ($id)
 
static loadMultiple (array $ids=NULL)
 
static create (array $values=array())
 
- Static Public Member Functions inherited from FieldableEntityInterface
static baseFieldDefinitions (EntityTypeInterface $entity_type)
 

Additional Inherited Members

- Data Fields inherited from ContentEntityBase
const TRANSLATION_REMOVED = 0
 
const TRANSLATION_EXISTING = 1
 
const TRANSLATION_CREATED = 2
 
- Protected Member Functions inherited from ContentEntityBase
 getLanguages ()
 
 clearTranslationCache ()
 
 getTranslatedField ($name, $langcode)
 
 setDefaultLangcode ()
 
 updateFieldLangcodes ($langcode)
 
 initializeTranslation ($langcode)
 
 getEntityKey ($key)
 
- Protected Member Functions inherited from Entity
 entityManager ()
 
 entityTypeManager ()
 
 languageManager ()
 
 uuidGenerator ()
 
 linkTemplates ()
 
 urlRouteParameters ($rel)
 
 invalidateTagsOnSave ($update)
 
- Static Protected Member Functions inherited from Entity
static invalidateTagsOnDelete (EntityTypeInterface $entity_type, array $entities)
 
- Protected Attributes inherited from ContentEntityBase
 $values = array()
 
 $fields = array()
 
 $fieldDefinitions
 
 $languages
 
 $langcodeKey
 
 $defaultLangcodeKey
 
 $activeLangcode = LanguageInterface::LANGCODE_DEFAULT
 
 $defaultLangcode
 
 $translations = array()
 
 $translationInitialize = FALSE
 
 $newRevision = FALSE
 
 $isDefaultRevision = TRUE
 
 $entityKeys = array()
 
 $translatableEntityKeys = array()
 
 $validated = FALSE
 
 $validationRequired = FALSE
 
- Protected Attributes inherited from Entity
 $entityTypeId
 
 $enforceIsNew
 
 $typedData
 

Detailed Description

Defines the file entity class.

( id = "file", label = ("File"), handlers = { "storage" = "Drupal\file\FileStorage", "storage_schema" = "Drupal\file\FileStorageSchema", "access" = "Drupal\file\FileAccessControlHandler", "views_data" = "Drupal\file\FileViewsData", }, base_table = "file_managed", entity_keys = { "id" = "fid", "label" = "filename", "langcode" = "langcode", "uuid" = "uuid" } )

Member Function Documentation

static baseFieldDefinitions ( EntityTypeInterface  $entity_type)
static

{}

References BaseFieldDefinition\create(), and t().

Here is the call graph for this function:

getCreatedTime ( )

{Returns the file entity creation timestamp.

Returns
int Creation timestamp of the file entity.
}

Implements FileInterface.

getFilename ( )

{Returns the name of the file.This may differ from the basename of the URI if the file is renamed to avoid overwriting an existing file.

Returns
string Name of the file.
}

Implements FileInterface.

getFileUri ( )

{Returns the URI of the file.

Returns
string The URI of the file, e.g. public://directory/file.jpg.
}

Implements FileInterface.

Referenced by File\preSave(), and File\url().

Here is the caller graph for this function:

getMimeType ( )

{Returns the MIME type of the file.

Returns
string The MIME type of the file, e.g. image/jpeg or text/xml.
}

Implements FileInterface.

getOwner ( )

{Returns the entity owner's user entity.

Returns
The owner user entity.
}

Implements EntityOwnerInterface.

getOwnerId ( )

{Returns the entity owner's user ID.

Returns
int|null The owner user ID, or NULL in case the user ID field has not been set on the entity.
}

Implements EntityOwnerInterface.

getSize ( )

{Returns the size of the file.

Returns
string The size of the file in bytes.
}

Implements FileInterface.

isPermanent ( )

{Returns TRUE if the file is permanent.

Returns
bool TRUE if the file status is permanent.
}

Implements FileInterface.

References FILE_STATUS_PERMANENT.

isTemporary ( )

{Returns TRUE if the file is temporary.

Returns
bool TRUE if the file status is temporary.
}

Implements FileInterface.

static preCreate ( EntityStorageInterface  $storage,
array &  $values 
)
static

{}

References drupal_basename(), and Drupal\service().

Here is the call graph for this function:

static preDelete ( EntityStorageInterface  $storage,
array  $entities 
)
static

{}

References file_unmanaged_delete(), and Drupal\service().

Here is the call graph for this function:

preSave ( EntityStorageInterface  $storage)

{}

References File\getFileUri(), and File\setSize().

Here is the call graph for this function:

setFilename (   $filename)

{Sets the name of the file.

Parameters
string$filenameThe file name that corresponds to this file. May differ from the basename of the URI and changing the filename does not change the URI.
}

Implements FileInterface.

setFileUri (   $uri)

{Sets the URI of the file.

Parameters
string$uriThe URI of the file, e.g. public://directory/file.jpg. Does not change the location of the file.
}

Implements FileInterface.

setMimeType (   $mime)

{Sets the MIME type of the file.

Parameters
string$mimeThe MIME type of the file, e.g. image/jpeg or text/xml.
}

Implements FileInterface.

setOwner ( UserInterface  $account)

{}

References ContentEntityBase\set().

Here is the call graph for this function:

setOwnerId (   $uid)

{Sets the entity owner's user ID.

Parameters
int$uidThe owner user id.
Returns
$this
}

Implements EntityOwnerInterface.

References ContentEntityBase\set().

Here is the call graph for this function:

setPermanent ( )

{Sets the file status to permanent.}

Implements FileInterface.

References FILE_STATUS_PERMANENT.

setSize (   $size)

{Sets the size of the file.

Parameters
int$sizeThe size of the file in bytes.
}

Implements FileInterface.

Referenced by File\preSave().

Here is the caller graph for this function:

setTemporary ( )

{Sets the file status to temporary.}

Implements FileInterface.

url (   $rel = 'canonical',
  $options = array() 
)

{Gets the public URL for this entity.

Parameters
string$relThe link relationship type, for example: canonical or edit-form.
array$optionsSee ::generateFromRoute() for the available options.
Returns
string The URL for this entity.
Deprecated:
in Drupal 8.0.0, intended to be removed in Drupal 9.0.0 Please use toUrl() instead.
See Also
::toUrl
}

Implements EntityInterface.

References file_create_url(), and File\getFileUri().

Here is the call graph for this function:


The documentation for this class was generated from the following file: