From: Chuck Hagenbuch Date: Thu, 14 Jan 2010 22:37:09 +0000 (-0500) Subject: Use the new injector bindings to get Horde_Db instances X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8a9dc59523aad41935819a53df3c9be162497a7a;p=horde.git Use the new injector bindings to get Horde_Db instances This replaces all usage of the deprecated Horde_Db_Factory --- diff --git a/content/app/controllers/ApplicationController.php b/content/app/controllers/ApplicationController.php index 1425d0bb5..87d2898f0 100644 --- a/content/app/controllers/ApplicationController.php +++ b/content/app/controllers/ApplicationController.php @@ -16,12 +16,7 @@ class Content_ApplicationController extends Horde_Controller_Base { $CONTENT_DIR = dirname(__FILE__) . '/../'; - $GLOBALS['conf']['sql']['adapter'] = $GLOBALS['conf']['sql']['phptype'] == 'mysqli' ? 'mysqli' : 'pdo_' . $GLOBALS['conf']['sql']['phptype']; - - // @TODO use this - // $injector = new Horde_Injector(); - - $this->db = Horde_Db_Adapter::factory($GLOBALS['conf']['sql']); + $this->db = $GLOBALS['injector']->getInstance('db-writer'); $context = array('dbAdapter' => $this->db); $this->typeManager = new Content_Types_Manager($context); @@ -35,5 +30,4 @@ class Content_ApplicationController extends Horde_Controller_Base $this->tagger = new Content_Tagger($context); } - } diff --git a/framework/Image/tests/im.php b/framework/Image/tests/im.php index 1cf395fcc..385d86581 100644 --- a/framework/Image/tests/im.php +++ b/framework/Image/tests/im.php @@ -10,8 +10,7 @@ define('HORDE_BASE', '/var/www/html/horde'); $horde_authentication = 'none'; require_once HORDE_BASE . '/lib/base.php'; -$GLOBALS['conf']['sql']['adapter'] = $GLOBALS['conf']['sql']['phptype'] == 'mysqli' ? 'mysqli' : 'pdo_' . $GLOBALS['conf']['sql']['phptype']; -$db = Horde_Db_Adapter::factory($GLOBALS['conf']['sql']); +$db = $GLOBALS['injector']->getInstance('db-writer'); // Putting these here so they don't interfere with timing/memory data when // profiling. diff --git a/framework/Rdo/examples/Horde/Rdo/Clotho.php b/framework/Rdo/examples/Horde/Rdo/Clotho.php index 1835e7c95..b5063881d 100644 --- a/framework/Rdo/examples/Horde/Rdo/Clotho.php +++ b/framework/Rdo/examples/Horde/Rdo/Clotho.php @@ -31,7 +31,7 @@ class Clotho_Mapper extends Horde_Rdo_Mapper { public function getAdapter() { - return Horde_Db_Adapter::factory($GLOBALS['conf']['sql']); + return $GLOBALS['injector']->getInstance('db-writer'); } } diff --git a/framework/Rdo/examples/Horde/Rdo/User.php b/framework/Rdo/examples/Horde/Rdo/User.php index a25988564..c59e9f9ce 100644 --- a/framework/Rdo/examples/Horde/Rdo/User.php +++ b/framework/Rdo/examples/Horde/Rdo/User.php @@ -21,7 +21,7 @@ class UserMapper extends Horde_Rdo_Mapper { public function getAdapter() { - return Horde_Db_Adapter::factory($GLOBALS['conf']['sql']); + return $GLOBALS['injector']->getInstance('db-writer'); } } diff --git a/horde/bin/db_migrate b/horde/bin/db_migrate index c1d557c58..9a7474364 100755 --- a/horde/bin/db_migrate +++ b/horde/bin/db_migrate @@ -26,8 +26,7 @@ $cli = Horde_Cli::singleton(); new Horde_Application(array('authentication' => 'none')); // Get a database connection -$GLOBALS['conf']['sql']['adapter'] = $GLOBALS['conf']['sql']['phptype'] == 'mysqli' ? 'mysqli' : 'pdo_' . $GLOBALS['conf']['sql']['phptype']; -$db = Horde_Db_Adapter::factory($GLOBALS['conf']['sql']); +$db = $GLOBALS['injector']->getInstance('db-manager'); // Parse command line arguments array_shift($_SERVER['argv']); diff --git a/kronolith/lib/Tagger.php b/kronolith/lib/Tagger.php index 0c390e4ba..0e5655278 100644 --- a/kronolith/lib/Tagger.php +++ b/kronolith/lib/Tagger.php @@ -38,14 +38,7 @@ class Kronolith_Tagger } // Set up the context for the tagger and related content classes - $GLOBALS['conf']['sql']['adapter'] = $GLOBALS['conf']['sql']['phptype'] == 'mysqli' - ? 'mysqli' - : 'pdo_' . $GLOBALS['conf']['sql']['phptype']; - if (!empty($GLOBALS['conf']['sql']['params']['hostspec'])) { - $GLOBALS['conf']['sql']['params']['host'] = $GLOBALS['conf']['sql']['params']['hostspec']; - } - - $context = array('dbAdapter' => Horde_Db_Adapter::factory($GLOBALS['conf']['sql'])); + $context = array('dbAdapter' => $GLOBALS['injector']->getInstance('db-writer')); $user_mgr = new Content_Users_Manager($context); $type_mgr = new Content_Types_Manager($context);