Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / file / src / FileUsage / FileUsageInterface.php
1 <?php
2
3 namespace Drupal\file\FileUsage;
4
5 use Drupal\file\FileInterface;
6
7 /**
8  * File usage backend interface.
9  */
10 interface FileUsageInterface {
11
12   /**
13    * Records that a module is using a file.
14    *
15    * Examples:
16    * - A module that associates files with nodes, so $type would be
17    *   'node' and $id would be the node's nid. Files for all revisions are
18    *   stored within a single nid.
19    * - The User module associates an image with a user, so $type would be 'user'
20    *   and the $id would be the user's uid.
21    *
22    * @param \Drupal\file\FileInterface $file
23    *   A file entity.
24    * @param string $module
25    *   The name of the module using the file.
26    * @param string $type
27    *   The type of the object that contains the referenced file.
28    * @param string $id
29    *   The unique ID of the object containing the referenced file.
30    * @param int $count
31    *   (optional) The number of references to add to the object. Defaults to 1.
32    */
33   public function add(FileInterface $file, $module, $type, $id, $count = 1);
34
35   /**
36    * Removes a record to indicate that a module is no longer using a file.
37    *
38    * @param \Drupal\file\FileInterface $file
39    *   A file entity.
40    * @param string $module
41    *   The name of the module using the file.
42    * @param string $type
43    *   (optional) The type of the object that contains the referenced file. May
44    *   be omitted if all module references to a file are being deleted. Defaults
45    *   to NULL.
46    * @param string $id
47    *   (optional) The unique ID of the object containing the referenced file.
48    *   May be omitted if all module references to a file are being deleted.
49    *   Defaults to NULL.
50    * @param int $count
51    *   (optional) The number of references to delete from the object. Defaults
52    *   to 1. Zero may be specified to delete all references to the file within a
53    *   specific object.
54    */
55   public function delete(FileInterface $file, $module, $type = NULL, $id = NULL, $count = 1);
56
57   /**
58    * Determines where a file is used.
59    *
60    * @param \Drupal\file\FileInterface $file
61    *   A file entity.
62    *
63    * @return array
64    *   A nested array with usage data. The first level is keyed by module name,
65    *   the second by object type and the third by the object id. The value of
66    *   the third level contains the usage count.
67    */
68   public function listUsage(FileInterface $file);
69
70 }