cleanups
[m6w6/pq-gateway] / lib / pq / Mapper / Storage.php
1 <?php
2
3 namespace pq\Mapper;
4
5 class Storage implements StorageInterface
6 {
7 /**
8 *
9 * @var pq\Mapper\MapInterface
10 */
11 private $map;
12
13 /**
14 * @var \pq\Gateway\Table
15 */
16 private $gateway;
17
18 function __construct(MapInterface $map) {
19 $this->map = $map;
20 $this->gateway = $map->getGateway();
21 }
22
23 function find($where = [], $order = null, $limit = null, $offset = null) {
24 /* @var pq\Gateway\Rowset $rowset */
25 $rowset = $this->gateway->find($where, $order, $limit, $offset);
26 return $this->map->mapAll($rowset);
27 }
28
29 function delete($object) {
30 $cache = $this->map->getObjects();
31 $row = $cache->asRow($object)->delete();
32 $cache->resetObject($row);
33 $cache->resetRow($object);
34 }
35
36 function save($object) {
37 $this->map->unmap($object);
38 }
39
40 }