]> git.mxchange.org Git - friendica.git/blob - src/Model/Storage/IStorage.php
Merge pull request #8250 from annando/issue-8233
[friendica.git] / src / Model / Storage / IStorage.php
1 <?php
2 /**
3  * @file src/Model/Storage/IStorage.php
4  * Storage backend system
5  */
6
7 namespace Friendica\Model\Storage;
8
9 /**
10  * Interface for storage backends
11  */
12 interface IStorage
13 {
14         /**
15          * Get data from backend
16          *
17          * @param string $reference Data reference
18          *
19          * @return string
20          */
21         public function get(string $reference);
22
23         /**
24          * Put data in backend as $ref. If $ref is not defined a new reference is created.
25          *
26          * @param string $data      Data to save
27          * @param string $reference Data reference. Optional.
28          *
29          * @return string Saved data reference
30          */
31         public function put(string $data, string $reference = "");
32
33         /**
34          * Remove data from backend
35          *
36          * @param string $reference Data reference
37          *
38          * @return boolean  True on success
39          */
40         public function delete(string $reference);
41
42         /**
43          * Get info about storage options
44          *
45          * @return array
46          *
47          * This method return an array with informations about storage options
48          * from which the form presented to the user is build.
49          *
50          * The returned array is:
51          *
52          *    [
53          *      'option1name' => [ ..info.. ],
54          *      'option2name' => [ ..info.. ],
55          *      ...
56          *    ]
57          *
58          * An empty array can be returned if backend doesn't have any options
59          *
60          * The info array for each option MUST be as follows:
61          *
62          *    [
63          *      'type',      // define the field used in form, and the type of data.
64          *                   // one of 'checkbox', 'combobox', 'custom', 'datetime',
65          *                   // 'input', 'intcheckbox', 'password', 'radio', 'richtext'
66          *                   // 'select', 'select_raw', 'textarea'
67          *
68          *      'label',     // Translatable label of the field
69          *      'value',     // Current value
70          *      'help text', // Translatable description for the field
71          *      extra data   // Optional. Depends on 'type':
72          *                   // select: array [ value => label ] of choices
73          *                   // intcheckbox: value of input element
74          *                   // select_raw: prebuild html string of < option > tags
75          *    ]
76          *
77          * See https://github.com/friendica/friendica/wiki/Quick-Template-Guide
78          */
79         public function getOptions();
80
81         /**
82          * Validate and save options
83          *
84          * @param array $data Array [optionname => value] to be saved
85          *
86          * @return array  Validation errors: [optionname => error message]
87          *
88          * Return array must be empty if no error.
89          */
90         public function saveOptions(array $data);
91
92         /**
93          * The name of the backend
94          *
95          * @return string
96          */
97         public function __toString();
98
99         /**
100          * The name of the backend
101          *
102          * @return string
103          */
104         public static function getName();
105 }