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