From 58919afe451ad5b2088d61ff1c856f44dd522b32 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 7 May 2012 21:10:51 +0200 Subject: add interfaces for database adapter --- src/phorkie/Database.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/phorkie/Database.php') diff --git a/src/phorkie/Database.php b/src/phorkie/Database.php index 9854e7c..786cfe0 100644 --- a/src/phorkie/Database.php +++ b/src/phorkie/Database.php @@ -3,19 +3,30 @@ namespace phorkie; class Database { + public $prefix = '\phorkie\Database_Adapter_Null'; + + public function __construct() + { + if ($GLOBALS['phorkie']['cfg']['elasticsearch'] != '') { + $this->prefix = '\phorkie\Database_Adapter_Elasticsearch'; + } + } public function getSearch() { - return new Database_Adapter_Elasticsearch_Search(); + $class = $this->prefix . '_Search'; + return new $class(); } public function getIndexer() { - return new Database_Adapter_Elasticsearch_Indexer(); + $class = $this->prefix . '_Indexer'; + return new $class(); } public function getSetup() { - return new Database_Adapter_Elasticsearch_Setup(); + $class = $this->prefix . '_Setup'; + return new $class(); } } -- cgit v1.2.3