Use the new injector bindings to get Horde_Db instances
authorChuck Hagenbuch <chuck@horde.org>
Thu, 14 Jan 2010 22:37:09 +0000 (17:37 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Thu, 14 Jan 2010 22:37:52 +0000 (17:37 -0500)
This replaces all usage of the deprecated Horde_Db_Factory

content/app/controllers/ApplicationController.php
framework/Image/tests/im.php
framework/Rdo/examples/Horde/Rdo/Clotho.php
framework/Rdo/examples/Horde/Rdo/User.php
horde/bin/db_migrate
kronolith/lib/Tagger.php

index 1425d0b..87d2898 100644 (file)
@@ -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);
     }
-
 }
index 1cf395f..385d865 100644 (file)
@@ -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.
index 1835e7c..b506388 100644 (file)
@@ -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');
     }
 
 }
index a259885..c59e9f9 100644 (file)
@@ -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');
     }
 
 }
index c1d557c..9a74743 100755 (executable)
@@ -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']);
index 0c390e4..0e56552 100644 (file)
@@ -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);