Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / file_mdm / src / FileMetadataInterface.php
1 <?php
2
3 namespace Drupal\file_mdm;
4
5 /**
6  * Provides an interface for file metadata objects.
7  */
8 interface FileMetadataInterface {
9
10   /**
11    * Metadata not loaded.
12    */
13   const NOT_LOADED = 0;
14
15   /**
16    * Metadata loaded by code.
17    */
18   const LOADED_BY_CODE = 1;
19
20   /**
21    * Metadata loaded from cache.
22    */
23   const LOADED_FROM_CACHE = 2;
24
25   /**
26    * Metadata loaded from file.
27    */
28   const LOADED_FROM_FILE = 3;
29
30   /**
31    * Gets the URI of the file.
32    *
33    * @return string|null
34    *   The URI of the file, or a local path.
35    */
36   public function getUri();
37
38   /**
39    * Gets the local filesystem URI to the temporary file.
40    *
41    * @return string|null
42    *   The URI, or a local path, of the temporary file.
43    */
44   public function getLocalTempPath();
45
46   /**
47    * Sets the local filesystem URI to the temporary file.
48    *
49    * @param string $temp_uri
50    *   A URI to a temporary file.
51    *
52    * @return $this
53    */
54   public function setLocalTempPath($temp_uri);
55
56   /**
57    * Copies the file at URI to a local temporary file.
58    *
59    * @param string $temp_uri
60    *   (optional) a URI to a temporary file. If NULL, a temp URI will be
61    *   defined by the operation. Defaults to NULL.
62    *
63    * @return bool
64    *   TRUE if the file was copied successfully, FALSE
65    *   otherwise.
66    */
67   public function copyUriToTemp($temp_uri = NULL);
68
69   /**
70    * Copies the local temporary file to the destination URI.
71    *
72    * @return bool
73    *   TRUE if the file was copied successfully, FALSE
74    *   otherwise.
75    */
76   public function copyTempToUri();
77
78   /**
79    * Gets a FileMetadata plugin instance.
80    *
81    * @param string $metadata_id
82    *   The id of the plugin whose instance is to be returned. If it is does
83    *   not exist, an instance is created.
84    *
85    * @return \Drupal\file_mdm\Plugin\FileMetadataPluginInterface|null
86    *   The FileMetadata plugin instance. NULL if no plugin is found.
87    */
88   public function getFileMetadataPlugin($metadata_id);
89
90   /**
91    * Returns a list of supported metadata keys.
92    *
93    * @param string $metadata_id
94    *   The id of the FileMetadata plugin.
95    * @param mixed $options
96    *   (optional) Allows specifying additional options to control the list of
97    *   metadata keys returned.
98    *
99    * @return array
100    *   A simple array of metadata keys supported.
101    */
102   public function getSupportedKeys($metadata_id, $options = NULL);
103
104   /**
105    * Gets a metadata element.
106    *
107    * @param string $metadata_id
108    *   The id of the FileMetadata plugin.
109    * @param mixed|null $key
110    *   A key to determine the metadata element to be returned. If NULL, the
111    *   entire metadata will be returned.
112    *
113    * @return mixed
114    *   The value of the element specified by $key. If $key is NULL, the entire
115    *   metadata.
116    */
117   public function getMetadata($metadata_id, $key = NULL);
118
119   /**
120    * Removes a metadata element.
121    *
122    * @param string $metadata_id
123    *   The id of the FileMetadata plugin.
124    * @param mixed $key
125    *   A key to determine the metadata element to be removed.
126    *
127    * @return bool
128    *   TRUE if metadata was removed successfully, FALSE otherwise.
129    */
130   public function removeMetadata($metadata_id, $key);
131
132   /**
133    * Sets a metadata element.
134    *
135    * @param string $metadata_id
136    *   The id of the FileMetadata plugin.
137    * @param mixed $key
138    *   A key to determine the metadata element to be changed.
139    * @param mixed $value
140    *   The value to change the metadata element to.
141    *
142    * @return bool
143    *   TRUE if metadata was changed successfully, FALSE otherwise.
144    */
145   public function setMetadata($metadata_id, $key, $value);
146
147   /**
148    * Checks if file metadata has been already loaded.
149    *
150    * @param string $metadata_id
151    *   The id of the FileMetadata plugin.
152    *
153    * @return bool
154    *   TRUE if metadata is loaded, FALSE otherwise.
155    */
156   public function isMetadataLoaded($metadata_id);
157
158   /**
159    * Loads file metadata.
160    *
161    * @param string $metadata_id
162    *   The id of the FileMetadata plugin.
163    * @param mixed $metadata
164    *   The file metadata associated to the file at URI.
165    *
166    * @return bool
167    *   TRUE if metadata was loaded successfully, FALSE otherwise.
168    */
169   public function loadMetadata($metadata_id, $metadata);
170
171   /**
172    * Loads file metadata from a cache entry.
173    *
174    * @param string $metadata_id
175    *   The id of the FileMetadata plugin.
176    *
177    * @return bool
178    *   TRUE if metadata was loaded successfully, FALSE otherwise.
179    */
180   public function loadMetadataFromCache($metadata_id);
181
182   /**
183    * Caches metadata for file at URI.
184    *
185    * Uses the 'file_mdm' cache bin.
186    *
187    * @param string $metadata_id
188    *   The id of the FileMetadata plugin.
189    * @param array $tags
190    *   (optional) An array of cache tags to save to cache.
191    *
192    * @return bool
193    *   TRUE if metadata was saved successfully, FALSE otherwise.
194    */
195   public function saveMetadataToCache($metadata_id, array $tags = []);
196
197   /**
198    * Saves metadata to file at URI.
199    *
200    * @param string $metadata_id
201    *   The id of the FileMetadata plugin.
202    *
203    * @return bool
204    *   TRUE if metadata was saved successfully, FALSE otherwise.
205    */
206   public function saveMetadataToFile($metadata_id);
207
208 }