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