DatabaseFileUsageBackend
class DatabaseFileUsageBackend extends FileUsageBase (View source)
Defines the database file usage backend. This is the default Drupal backend.
Properties
| protected ConfigFactoryInterface | $configFactory | The config factory. |
from FileUsageBase |
| protected Connection | $connection | The database connection used to store file usage information. |
|
| protected string | $tableName | The name of the SQL table used to store file usage information. |
Methods
__construct(ConfigFactoryInterface $config_factory, Connection $connection, string $table = 'file_usage')
Construct the DatabaseFileUsageBackend.
add(FileInterface $file, string $module, string $type, string $id, int $count = 1)
Records that a module is using a file.
delete(FileInterface $file, string $module, string $type = NULL, string $id = NULL, int $count = 1)
Removes a record to indicate that a module is no longer using a file.
array
Details
__construct(ConfigFactoryInterface $config_factory, Connection $connection, string $table = 'file_usage')
Construct the DatabaseFileUsageBackend.
add(FileInterface $file, string $module, string $type, string $id, int $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.
delete(FileInterface $file, string $module, string $type = NULL, string $id = NULL, int $count = 1)
Removes a record to indicate that a module is no longer using a file.
array
listUsage(FileInterface $file)
Determines where a file is used.