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 = '');
];
-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
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
{
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);
}
```
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.
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
{
}
```
-### `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.
<?php
namespace Friendica\Addon\samplestorage;
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
use Friendica\Core\Config\IConfig;
use Friendica\Core\L10n;
-class SampleStorageBackend implements ISelectableStorage
+class SampleStorageBackend implements IWritableStorage
{
const NAME = 'Sample Storage';
**Theoretically - until tests for Addons are enabled too - create a test class with the name `addon/tests/SampleStorageTest.php`:
```php
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
use Friendica\Test\src\Model\Storage\StorageTest;
class SampleStorageTest extends StorageTest
}
// Assertion for the option array you return for your new StorageClass
- protected function assertOption(ISelectableStorage $storage)
+ protected function assertOption(IWritableStorage $storage)
{
$this->assertEquals([
'filename' => [