X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=doc%2FAddonStorageBackend.md;h=f4773acb89b81376eb4c53984d36d65789d3c3b0;hb=6d0f6babe3387d16c768fa0f779ee65acde1b5d1;hp=d42c8bbbd7f7aadd87e1804c8ad0fcb1bdbb2919;hpb=f8d2f81d817bbeb01026bb589f15336043e5597a;p=friendica.git diff --git a/doc/AddonStorageBackend.md b/doc/AddonStorageBackend.md index d42c8bbbd7..f4773acb89 100644 --- a/doc/AddonStorageBackend.md +++ b/doc/AddonStorageBackend.md @@ -10,29 +10,48 @@ A storage backend is implemented as a class, and the plugin register the class t The class must live in `Friendica\Addon\youraddonname` namespace, where `youraddonname` the folder name of your addon. -The class must implement `Friendica\Model\Storage\IStorage` interface. All method in the interface must be implemented: +There are two different interfaces you need to implement. -namespace Friendica\Model\Storage; +### `IWritableStorage` + +The class must implement `Friendica\Model\Storage\IWritableStorage` interface. All method in the interface must be implemented: ```php -interface IStorage +namespace Friendica\Model\Storage\IWritableStorage; + +interface IWritableStorage { - public static function get($ref); - public static function put($data, $ref = ""); - public static function delete($ref); - public static function getOptions(); - public static function saveOptions($data); + public function get(string $reference); + public function put(string $data, string $reference = ''); + public function delete(string $reference); + public function __toString(); + public static function getName(); } ``` -- `get($ref)` returns data pointed by `$ref` -- `put($data, $ref)` saves data in `$data` to position `$ref`, or a new position if `$ref` is empty. -- `delete($ref)` delete data pointed by `$ref` +- `get(string $reference)` returns data pointed by `$reference` +- `put(string $data, string $reference)` saves data in `$data` to position `$reference`, or a new position if `$reference` is empty. +- `delete(string $reference)` delete data pointed by `$reference` + +### `IStorageConfiguration` Each storage backend can have options the admin can set in admin page. +To make the options possible, you need to implement the `Friendica\Model\Storage\IStorageConfiguration` interface. + +All methods in the interface must be implemented: + +```php +namespace Friendica\Model\Storage\IStorageConfiguration; + +interface IStorageConfiguration +{ + public function getOptions(); + public function saveOptions(array $data); +} +``` - `getOptions()` returns an array with details about each option to build the interface. -- `saveOptions($data)` get `$data` from admin page, validate it and save it. +- `saveOptions(array $data)` get `$data` from admin page, validate it and save it. The array returned by `getOptions()` is defined as: @@ -50,7 +69,7 @@ The info array for each option is defined as: 'type', define the field used in form, and the type of data. -one of 'checkbox', 'combobox', 'custom', 'datetime', 'input', 'intcheckbox', 'password', 'radio', 'richtext', 'select', 'select_raw', 'textarea', 'yesno' +one of 'checkbox', 'combobox', 'custom', 'datetime', 'input', 'intcheckbox', 'password', 'radio', 'richtext', 'select', 'select_raw', 'textarea' 'label', @@ -71,28 +90,90 @@ Optional. Depends on which 'type' this option is: - 'select': array `[ value => label ]` of choices - 'intcheckbox': value of input element - 'select_raw': prebuild html string of `