| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation App Framework — Store contract. |
| 4 |
* |
| 5 |
* Durable key/value storage an app may write: per acting user |
| 6 |
* (`user` scope) or site-wide (`site` scope). The host decides where |
| 7 |
* it lives — user meta and options on WordPress, files or a table on |
| 8 |
* a bare PHP host. Keys arrive already namespaced by the app. |
| 9 |
* |
| 10 |
* @package OpenStation |
| 11 |
*/ |
| 12 |
|
| 13 |
namespace OpenStation\App\Contracts; |
| 14 |
|
| 15 |
// Direct access, unless a standalone host is booting on bare PHP. |
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
defined( 'OPENSTATION_STANDALONE' ) || exit; |
| 18 |
} |
| 19 |
|
| 20 |
interface Store { |
| 21 |
|
| 22 |
/** |
| 23 |
* Read a stored value. |
| 24 |
* |
| 25 |
* @param string $scope `user` | `site`. |
| 26 |
* @param string $key Key. |
| 27 |
* @param mixed $fallback Returned when unset. |
| 28 |
* @return mixed |
| 29 |
*/ |
| 30 |
public function get( $scope, $key, $fallback = null ); |
| 31 |
|
| 32 |
/** |
| 33 |
* Write a value. |
| 34 |
* |
| 35 |
* @param string $scope `user` | `site`. |
| 36 |
* @param string $key Key. |
| 37 |
* @param mixed $value Serialisable value. |
| 38 |
* @return void |
| 39 |
*/ |
| 40 |
public function set( $scope, $key, $value ); |
| 41 |
|
| 42 |
/** |
| 43 |
* Remove a value. |
| 44 |
* |
| 45 |
* @param string $scope `user` | `site`. |
| 46 |
* @param string $key Key. |
| 47 |
* @return void |
| 48 |
*/ |
| 49 |
public function delete( $scope, $key ); |
| 50 |
} |
| 51 |
|