1 | <?php |
||
31 | class StandardObjectStorage |
||
32 | { |
||
33 | /** |
||
34 | * An array of fetched object, accessible via table name and primary key. |
||
35 | * If the primary key is split on several columns, access is done by an array of columns, serialized. |
||
36 | * |
||
37 | * @var array<string, array<string, TDBMObject>> |
||
38 | */ |
||
39 | private $objects = array(); |
||
40 | |||
41 | /** |
||
42 | * Sets an object in the storage. |
||
43 | * |
||
44 | * @param string $tableName |
||
45 | * @param string $id |
||
46 | * @param TDBMObject $dbRow |
||
47 | */ |
||
48 | public function set($tableName, $id, DbRow $dbRow) |
||
52 | |||
53 | /** |
||
54 | * Checks if an object is in the storage. |
||
55 | * |
||
56 | * @param string $tableName |
||
57 | * @param string $id |
||
58 | * |
||
59 | * @return bool |
||
60 | */ |
||
61 | public function has($tableName, $id) |
||
65 | |||
66 | /** |
||
67 | * Returns an object from the storage (or null if no object is set). |
||
68 | * |
||
69 | * @param string $tableName |
||
70 | * @param string $id |
||
71 | * |
||
72 | * @return DbRow |
||
73 | */ |
||
74 | public function get($tableName, $id) |
||
82 | |||
83 | /** |
||
84 | * Removes an object from the storage. |
||
85 | * |
||
86 | * @param string $tableName |
||
87 | * @param string $id |
||
88 | */ |
||
89 | public function remove($tableName, $id) |
||
93 | |||
94 | /** |
||
95 | * Applies the callback to all objects. |
||
96 | * |
||
97 | * @param callable $callback |
||
98 | */ |
||
99 | public function apply(callable $callback) |
||
107 | } |
||
108 |