X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=doc%2FAddonStorageBackend.md;h=e54960252be4777350d381531a5514bc00c0f42e;hb=11943bbec4c5d8292e59f41790d9898f730376e8;hp=72e146779326829a77c40b69d11857f944bc9162;hpb=813db7956f360120588e7d0bf412a85b6e438324;p=friendica.git diff --git a/doc/AddonStorageBackend.md b/doc/AddonStorageBackend.md index 72e1467793..e54960252b 100644 --- a/doc/AddonStorageBackend.md +++ b/doc/AddonStorageBackend.md @@ -10,12 +10,12 @@ 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\ISelectableStorage` interface. All method in the interface must be implemented: +The class must implement `Friendica\Model\Storage\IWritableStorage` interface. All method in the interface must be implemented: -namespace Friendica\Model\ISelectableStorage; +namespace Friendica\Model\IWritableStorage; ```php -interface ISelectableStorage +interface IWritableStorage { public function get(string $reference); public function put(string $data, string $reference = ''); @@ -79,7 +79,7 @@ Each label should be translatable ]; -See doxygen documentation of `ISelectableStorage` interface for details about each method. +See doxygen documentation of `IWritableStorage` interface for details about each method. ## Register a storage backend class @@ -105,8 +105,9 @@ Each new Storage class should be added to the test-environment at [Storage Tests Add a new test class which's naming convention is `StorageClassTest`, which extend the `StorageTest` in the same directory. Override the two necessary instances: + ```php -use Friendica\Model\Storage\ISelectableStorage; +use Friendica\Model\Storage\IWritableStorage; abstract class StorageTest { @@ -114,7 +115,7 @@ abstract class StorageTest abstract protected function getInstance(); // Assertion for the option array you return for your new StorageClass - abstract protected function assertOption(ISelectableStorage $storage); + abstract protected function assertOption(IWritableStorage $storage); } ``` @@ -122,6 +123,14 @@ abstract class StorageTest There are two intended types of exceptions for storages +### `ReferenceStorageExecption` + +This storage exception should be used in case the caller tries to use an invalid references. +This could happen in case the caller tries to delete or update an unknown reference. +The implementation of the storage backend must not ignore invalid references. + +Avoid throwing the common `StorageExecption` instead of the `ReferenceStorageException` at this particular situation! + ### `StorageException` This is the common exception in case unexpected errors happen using the storage backend. @@ -130,9 +139,9 @@ If there's a predecessor to this exception (e.g. you caught an exception and are Example: ```php -use Friendica\Model\Storage\ISelectableStorage; +use Friendica\Model\Storage\IWritableStorage; -class ExampleStorage implements ISelectableStorage +class ExampleStorage implements IWritableStorage { public function get(string $reference) : string { @@ -145,14 +154,6 @@ class ExampleStorage implements ISelectableStorage } ``` -### `ReferenceStorageExecption` - -This storage exception should be used in case the caller tries to use an invalid references. -This could happen in case the caller tries to delete or update an unknown reference. -The implementation of the storage backend must not ignore invalid references. - -Avoid throwing the common `StorageExecption` instead of the `ReferenceStorageException` at this particular situation! - ## Example Here an hypotetical addon which register a useless storage backend. @@ -168,12 +169,12 @@ The file will be `addon/samplestorage/SampleStorageBackend.php`: assertEquals([ 'filename' => [