3 namespace Drupal\Component\PhpStorage;
6 * Stores and loads PHP code.
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.
14 interface PhpStorageInterface {
17 * Checks whether the PHP code exists in storage.
20 * The virtual file name. Can be a relative path.
23 * TRUE if the virtual file exists, FALSE otherwise.
25 public function exists($name);
28 * Loads PHP code from storage.
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).
37 * The virtual file name. Can be a relative path.
39 public function load($name);
42 * Saves PHP code to storage.
45 * The virtual file name. Can be a relative path.
47 * The PHP code to be saved.
50 * TRUE if the save succeeded, FALSE if it failed.
52 public function save($name, $code);
55 * Whether this is a writeable storage.
59 public function writeable();
62 * Deletes PHP code from storage.
65 * The virtual file name. Can be a relative path.
68 * TRUE if the delete succeeded, FALSE if it failed.
70 public function delete($name);
73 * Removes all files in this bin.
75 public function deleteAll();
78 * Gets the full file path.
81 * The virtual file name. Can be a relative path.
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.
87 public function getFullPath($name);
90 * Lists all the files in the storage.
95 public function listAll();
98 * Performs garbage collection on the storage.
100 * The storage may choose to delete expired or invalidated items.
102 public function garbageCollection();