]> git.mxchange.org Git - friendica.git/blob - src/Model/Storage/SystemResource.php
- Fixing SystemResource
[friendica.git] / src / Model / Storage / SystemResource.php
1 <?php
2 /**
3  * @file src/Model/Storage/SystemStorage.php
4  * @brief Storage backend system
5  */
6
7 namespace Friendica\Model\Storage;
8
9 use \BadMethodCallException;
10
11 /**
12  * @brief System resource storage class
13  *
14  * This class is used to load system resources, like images.
15  * Is not intended to be selectable by admins as default storage class.
16  */
17 class SystemResource implements IStorage
18 {
19         const NAME = 'SystemResource';
20
21         // Valid folders to look for resources
22         const VALID_FOLDERS = ["images"];
23
24         /**
25          * @inheritDoc
26          */
27         public function get(string $filename)
28         {
29                 $folder = dirname($filename);
30                 if (!in_array($folder, self::VALID_FOLDERS)) {
31                         return "";
32                 }
33                 if (!file_exists($filename)) {
34                         return "";
35                 }
36                 return file_get_contents($filename);
37         }
38
39         /**
40          * @inheritDoc
41          */
42         public function put(string $data, string $filename = '')
43         {
44                 throw new BadMethodCallException();
45         }
46
47         public function delete(string $filename)
48         {
49                 throw new BadMethodCallException();
50         }
51
52         /**
53          * @inheritDoc
54          */
55         public function getOptions()
56         {
57                 return [];
58         }
59
60         /**
61          * @inheritDoc
62          */
63         public function saveOptions(array $data)
64         {
65                 return [];
66         }
67
68         /**
69          * @inheritDoc
70          */
71         public function __toString()
72         {
73                 return self::NAME;
74         }
75
76         /**
77          * @inheritDoc
78          */
79         public static function getName()
80         {
81                 return self::NAME;
82         }
83 }