Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | namespace Flow\Data; |
4 | |
5 | /** |
6 | * Interface representing backend data stores. Typically they |
7 | * will be implemented in SQL with the DbStorage base class. |
8 | */ |
9 | interface ObjectStorage { |
10 | |
11 | /** |
12 | * Perform a single equality query. |
13 | * |
14 | * @param array $attributes Map of attributes the model must contain |
15 | * @param array $options Query options such as ORDER BY and LIMIT. |
16 | * @return array |
17 | */ |
18 | public function find( array $attributes, array $options = [] ); |
19 | |
20 | /** |
21 | * Perform the equivalent of array_map against self::find for multiple |
22 | * equality queries with the minimum of network round trips. |
23 | * |
24 | * @param array $queries list of queries to perform |
25 | * @param array $options Options to use for all queries |
26 | * @return array[] Array of results for every query |
27 | */ |
28 | public function findMulti( array $queries, array $options = [] ); |
29 | |
30 | /** |
31 | * @return array The list of columns that together uniquely identify a row |
32 | */ |
33 | public function getPrimaryKeyColumns(); |
34 | |
35 | /** |
36 | * Insert the specified row into the data store. |
37 | * |
38 | * @param array $rows An array of rows, each row is a map of columns => values. |
39 | * Currently, the old calling convention of a simple map of columns to values is |
40 | * also supported. |
41 | * @return array|false The resulting $row including any auto-assigned ids or false on failure |
42 | */ |
43 | public function insert( array $rows ); |
44 | |
45 | /** |
46 | * Perform all changes necessary to turn $old into $new in the data store. |
47 | * |
48 | * @param array $old Map of columns to values that was initially loaded. |
49 | * @param array $new Map of columns to values that the row should become. |
50 | * @return bool true when the row is successfully updated |
51 | */ |
52 | public function update( array $old, array $new ); |
53 | |
54 | /** |
55 | * Remove the specified row from the data store. |
56 | * |
57 | * @param array $row Map of columns to values. Must contain the primary key columns. |
58 | */ |
59 | public function remove( array $row ); |
60 | |
61 | /** |
62 | * Returns a boolean true/false to indicate if the result of a particular |
63 | * query is valid & can be cached. |
64 | * In some cases, the retrieved data should not be cached. E.g. revisions |
65 | * with external content: revision data may be loaded, but the content could |
66 | * not be fetched from external storage. That shouldn't persist in cache. |
67 | * |
68 | * @param array $row |
69 | * @return bool |
70 | */ |
71 | public function validate( array $row ); |
72 | } |