function FileUsageInterface::add
Same name in other branches
- 9 core/modules/file/src/FileUsage/FileUsageInterface.php \Drupal\file\FileUsage\FileUsageInterface::add()
- 10 core/modules/file/src/FileUsage/FileUsageInterface.php \Drupal\file\FileUsage\FileUsageInterface::add()
- 11.x core/modules/file/src/FileUsage/FileUsageInterface.php \Drupal\file\FileUsage\FileUsageInterface::add()
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 $file: A file entity.
string $module: The name of the module using the file.
string $type: The type of the object that contains the referenced file.
string $id: The unique ID of the object containing the referenced file.
int $count: (optional) The number of references to add to the object. Defaults to 1.
1 method overrides FileUsageInterface::add()
- FileUsageBase::add in core/
modules/ file/ src/ FileUsage/ FileUsageBase.php - Records that a module is using a file.
File
-
core/
modules/ file/ src/ FileUsage/ FileUsageInterface.php, line 33
Class
- FileUsageInterface
- File usage backend interface.
Namespace
Drupal\file\FileUsageCode
public function add(FileInterface $file, $module, $type, $id, $count = 1);
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.