Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Component / PhpStorage / PhpStorageInterface.php
1 <?php
2
3 namespace Drupal\Component\PhpStorage;
4
5 /**
6  * Stores and loads PHP code.
7  *
8  * Each interface function takes $name as a parameter. This is a virtual file
9  * name: for example, 'foo.php' or 'some/relative/path/to/foo.php'. The
10  * storage implementation may store these as files within the local file system,
11  * use a remote stream, combine multiple virtual files into an archive, store
12  * them in database records, or use some other storage technique.
13  */
14 interface PhpStorageInterface {
15
16   /**
17    * Checks whether the PHP code exists in storage.
18    *
19    * @param string $name
20    *   The virtual file name. Can be a relative path.
21    *
22    * @return bool
23    *   TRUE if the virtual file exists, FALSE otherwise.
24    */
25   public function exists($name);
26
27   /**
28    * Loads PHP code from storage.
29    *
30    * Depending on storage implementation, exists() checks can be expensive, so
31    * this function may be called for a file that doesn't exist, and that should
32    * not result in errors. This function does not return anything, so it is
33    * up to the caller to determine if any code was loaded (for example, check
34    * class_exists() or function_exists() for what was expected in the code).
35    *
36    * @param string $name
37    *   The virtual file name. Can be a relative path.
38    */
39   public function load($name);
40
41   /**
42    * Saves PHP code to storage.
43    *
44    * @param string $name
45    *   The virtual file name. Can be a relative path.
46    * @param string $code
47    *    The PHP code to be saved.
48    *
49    * @return bool
50    *   TRUE if the save succeeded, FALSE if it failed.
51    */
52   public function save($name, $code);
53
54   /**
55    * Whether this is a writeable storage.
56    *
57    * @return bool
58    */
59   public function writeable();
60
61   /**
62    * Deletes PHP code from storage.
63    *
64    * @param string $name
65    *   The virtual file name. Can be a relative path.
66    *
67    * @return bool
68    *   TRUE if the delete succeeded, FALSE if it failed.
69    */
70   public function delete($name);
71
72   /**
73    * Removes all files in this bin.
74    */
75   public function deleteAll();
76
77   /**
78    * Gets the full file path.
79    *
80    * @param string $name
81    *   The virtual file name. Can be a relative path.
82    *
83    * @return string|false
84    *   The full file path for the provided name. Return FALSE if the
85    *   implementation needs to prevent access to the file.
86    */
87   public function getFullPath($name);
88
89   /**
90    * Lists all the files in the storage.
91    *
92    * @return array
93    *   Array of filenames.
94    */
95   public function listAll();
96
97   /**
98    * Performs garbage collection on the storage.
99    *
100    * The storage may choose to delete expired or invalidated items.
101    */
102   public function garbageCollection();
103
104 }