3 namespace Drupal\Component\PhpStorage;
6 * Reads code as regular PHP files, but won't write them.
8 class FileReadOnlyStorage implements PhpStorageInterface {
11 * The directory where the files should be stored.
18 * Constructs this FileStorage object.
20 * @param $configuration
21 * An associative array, containing at least two keys (the rest are ignored):
22 * - directory: The directory where the files should be stored.
23 * - bin: The storage bin. Multiple storage objects can be instantiated with
24 * the same configuration, but for different bins.
26 public function __construct(array $configuration) {
28 $this->directory = $configuration['directory'] . '/' . $configuration['bin'];
34 public function exists($name) {
35 return file_exists($this->getFullPath($name));
41 public function load($name) {
42 // The FALSE returned on failure is enough for the caller to handle this,
43 // we do not want a warning too.
44 return (@include_once $this->getFullPath($name)) !== FALSE;
50 public function save($name, $code) {
57 public function delete($name) {
64 public function getFullPath($name) {
65 return $this->directory . '/' . $name;
71 public function writeable() {
78 public function deleteAll() {
85 public function listAll() {
87 if (file_exists($this->directory)) {
88 foreach (new \DirectoryIterator($this->directory) as $fileinfo) {
89 if (!$fileinfo->isDot()) {
90 $name = $fileinfo->getFilename();
91 if ($name != '.htaccess') {
103 public function garbageCollection() {