2013-09-08 01:00:34 +04:00
|
|
|
<?php
|
|
|
|
/**
|
2014-04-19 20:16:55 +04:00
|
|
|
* 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;
|
|
|
|
|
2014-04-20 14:14:42 +04:00
|
|
|
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;
|
2014-04-19 15:20:54 +04:00
|
|
|
$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':
|
2014-04-19 15:20:54 +04:00
|
|
|
return new \OCA\News\Db\Postgres\ItemMapper($this->db);
|
2013-09-08 01:00:34 +04:00
|
|
|
default:
|
2014-04-19 15:20:54 +04:00
|
|
|
return new ItemMapper($this->db);
|
2013-09-08 01:00:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|