Drupal 8  8.0.2
FileUsageBase Class Reference
Inheritance diagram for FileUsageBase:

Public Member Functions

 add (FileInterface $file, $module, $type, $id, $count=1)
 
 delete (FileInterface $file, $module, $type=NULL, $id=NULL, $count=1)
 
- Public Member Functions inherited from FileUsageInterface
 listUsage (FileInterface $file)
 

Detailed Description

Defines the base class for database file usage backend.

Member Function Documentation

add ( FileInterface  $file,
  $module,
  $type,
  $id,
  $count = 1 
)

{Records that a module is using a file.Examples:

  • A module that associates files with nodes, so $type would be 'node' and $id would be the node's nid. Files for all revisions are stored within a single nid.
  • The User module associates an image with a user, so $type would be 'user' and the $id would be the user's uid.
Parameters
\Drupal\file\FileInterface$fileA file entity.
string$moduleThe name of the module using the file.
string$typeThe type of the object that contains the referenced file.
int$idThe unique, numeric ID of the object containing the referenced file.
int$count(optional) The number of references to add to the object. Defaults to 1.
}

Implements FileUsageInterface.

References FileInterface\isPermanent(), EntityInterface\save(), and FileInterface\setPermanent().

Here is the call graph for this function:

delete ( FileInterface  $file,
  $module,
  $type = NULL,
  $id = NULL,
  $count = 1 
)

{Removes a record to indicate that a module is no longer using a file.

Parameters
\Drupal\file\FileInterface$fileA file entity.
string$moduleThe name of the module using the file.
string$type(optional) The type of the object that contains the referenced file. May be omitted if all module references to a file are being deleted. Defaults to NULL.
int$id(optional) The unique, numeric ID of the object containing the referenced file. May be omitted if all module references to a file are being deleted. Defaults to NULL.
int$count(optional) The number of references to delete from the object. Defaults to 1. Zero may be specified to delete all references to the file within a specific object.
}

Implements FileUsageInterface.

References Drupal\service().

Here is the call graph for this function:


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