3 namespace Friendica\Test\Util;
5 use Friendica\Model\Storage\IStorage;
7 use Friendica\Core\L10n\L10n;
10 * A backend storage example class
12 class SampleStorageBackend implements IStorage
14 const NAME = 'Sample Storage';
22 'input', // will use a simple text input
23 'The file to return', // the label
24 'sample', // the current value
25 'Enter the path to a file', // the help text
26 // no extra data for 'input' type..
29 /** @var array Just save the data in memory */
33 * SampleStorageBackend constructor.
35 * @param L10n $l10n The configuration of Friendica
37 * You can add here every dynamic class as dependency you like and add them to a private field
38 * Friendica automatically creates these classes and passes them as argument to the constructor
40 public function __construct(L10n $l10n)
45 public function get(string $reference)
47 // we return always the same image data. Which file we load is defined by
49 return $this->data[$reference] ?? null;
52 public function put(string $data, string $reference = '')
54 if ($reference === '') {
55 $reference = 'sample';
58 $this->data[$reference] = $data;
63 public function delete(string $reference)
65 if (isset($this->data[$reference])) {
66 unset($this->data[$reference]);
72 public function getOptions()
74 return $this->options;
77 public function saveOptions(array $data)
79 $this->options = $data;
81 // no errors, return empty array
82 return $this->options;
85 public function __toString()
90 public static function getName()