X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fpq-gateway;a=blobdiff_plain;f=lib%2Fpq%2FMapper%2FStorage.php;fp=lib%2Fpq%2FMapper%2FStorage.php;h=8e0fcb4df7b20f8b8347e8e241e3c9626f180820;hp=a27ea685dd96dc9864623685e8f130923fb72826;hb=d4d84fb9b85f0216bd611946d59054a606c71960;hpb=e6da4c7430e5c5b4ba482206e42aeebb4363d2b3 diff --git a/lib/pq/Mapper/Storage.php b/lib/pq/Mapper/Storage.php index a27ea68..8e0fcb4 100644 --- a/lib/pq/Mapper/Storage.php +++ b/lib/pq/Mapper/Storage.php @@ -4,53 +4,37 @@ namespace pq\Mapper; class Storage implements StorageInterface { - /** - * @var string - */ - private $class; - - /** - * @var \pq\Mapper\Mapper - */ - private $mapper; - /** * * @var pq\Mapper\MapInterface */ - private $mapping; + private $map; /** * @var \pq\Gateway\Table */ private $gateway; - function __construct(Mapper $mapper, $class) { - $this->class = $class; - $this->mapper = $mapper; - $this->mapping = $mapper->mapOf($class); - $this->gateway = $this->mapping->getGateway(); - } - - function getMapper() { - return $this->mapper; + function __construct(MapInterface $map) { + $this->map = $map; + $this->gateway = $map->getGateway(); } function find($where = [], $order = null, $limit = null, $offset = null) { /* @var pq\Gateway\Rowset $rowset */ $rowset = $this->gateway->find($where, $order, $limit, $offset); - return $this->mapping->mapAll($rowset); + return $this->map->mapAll($rowset); } function delete($object) { - $cache = $this->mapping->getObjects(); + $cache = $this->map->getObjects(); $row = $cache->asRow($object)->delete(); $cache->resetObject($row); $cache->resetRow($object); } - function persist($object) { - $this->mapping->unmap($object); + function save($object) { + $this->map->unmap($object); } } \ No newline at end of file