news/db/mapperfactory.php

41 строка
751 B
PHP
Исходник Обычный вид История

2013-09-08 01:00:34 +04:00
<?php
/**
* ownCloud - News
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Alessandro Cosentino <cosenal@gmail.com>
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Alessandro Cosentino 2012
* @copyright Bernhard Posselt 2012, 2014
*/
2013-09-08 01:00:34 +04:00
namespace OCA\News\Db;
use \OCP\IConfig;
2014-05-13 22:14:00 +04:00
use \OCP\IDb;
2013-09-08 01:00:34 +04:00
class MapperFactory {
2014-05-02 23:34:17 +04:00
private $dbType;
2014-05-13 00:45:24 +04:00
private $db;
2013-09-08 01:00:34 +04:00
2014-05-13 22:14:00 +04:00
public function __construct($dbType, IDb $db) {
2014-05-02 23:34:17 +04:00
$this->dbType = $dbType;
$this->db = $db;
2013-09-08 01:00:34 +04:00
}
public function getItemMapper() {
2014-05-02 23:34:17 +04:00
switch($this->dbType) {
2013-09-08 01:00:34 +04:00
case 'pgsql':
return new \OCA\News\Db\Postgres\ItemMapper($this->db);
2013-09-08 01:00:34 +04:00
default:
return new ItemMapper($this->db);
2013-09-08 01:00:34 +04:00
}
}
}