getInstance() -> factory()
authorMichael M Slusarz <slusarz@curecanti.org>
Sat, 25 Jul 2009 04:46:26 +0000 (22:46 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Sat, 25 Jul 2009 04:48:31 +0000 (22:48 -0600)
framework/Ajax/lib/Horde/Ajax/Imple.php
framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php
framework/Auth/lib/Horde/Auth/Cyrsql.php
framework/Auth/lib/Horde/Auth/Cyrus.php
framework/Auth/lib/Horde/Auth/Imap.php
framework/Imap_Client/lib/Horde/Imap/Client.php
framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php
framework/Imap_Client/test/Horde/Imap/test_client.php
framework/SpellChecker/lib/Horde/SpellChecker.php

index a290449..dc0bb50 100644 (file)
@@ -34,7 +34,7 @@ class Horde_Ajax_Imple
      * @return Horde_Ajax_Imple_Base  The newly created concrete instance.
      * @throws Horde_Exception
      */
-    static public function getInstance($driver, $params = array())
+    static public function factory($driver, $params = array())
     {
         if (is_array($driver)) {
             list($app, $driv_name) = $driver;
index b062ba9..80c5782 100644 (file)
@@ -93,7 +93,7 @@ class Horde_Ajax_Imple_SpellChecker extends Horde_Ajax_Imple_Base
         }
 
         try {
-            $speller = Horde_SpellChecker::getInstance($GLOBALS['conf']['spell']['driver'], $spellArgs);
+            $speller = Horde_SpellChecker::factory($GLOBALS['conf']['spell']['driver'], $spellArgs);
         } catch (Horde_Exception $e) {
             Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
             return array();
index 39f8ccc..9821f9b 100644 (file)
@@ -485,7 +485,7 @@ Horde_String::convertCharset($userName . $this->_separator . $value . '@' . $dom
         );
 
         try {
-            $this->_ob = Horde_Imap_Client::getInstance('Socket', $imap_config);
+            $this->_ob = Horde_Imap_Client::factory('Socket', $imap_config);
             $this->_ob->login();
         } catch (Horde_Imap_Client_Exception $e) {
             throw new Horde_Auth_Exception($e);
index b5141c1..e3b06d8 100644 (file)
@@ -234,7 +234,7 @@ class Horde_Auth_Cyrus extends Horde_Auth_Base
         );
 
         try {
-            $this->_ob = Horde_Imap_Client::getInstance('Socket', $imap_config);
+            $this->_ob = Horde_Imap_Client::factory('Socket', $imap_config);
             $this->_ob->login();
         } catch (Horde_Imap_Client_Exception $e) {
             throw new Horde_Auth_Exception($e);
index 294cf0f..181d32b 100644 (file)
@@ -167,7 +167,7 @@ class Horde_Auth_Imap extends Horde_Auth_Base
                 'username' => $user
             );
 
-            $this->_ob = Horde_Imap_Client::getInstance('Socket', $imap_config);
+            $this->_ob = Horde_Imap_Client::factory('Socket', $imap_config);
         }
 
         return $this->_ob;
index 295f534..ec7301d 100644 (file)
@@ -156,13 +156,14 @@ class Horde_Imap_Client
      *                                 instance.
      * @throws Horde_Imap_Client_Exception
      */
-    static public function getInstance($driver, $params = array())
+    static public function factory($driver, $params = array())
     {
-        $class = 'Horde_Imap_Client_' . strtr(basename($driver), '-', '_');
-        if (!class_exists($class)) {
-            throw new Horde_Imap_Client_Exception('Driver ' . $driver . ' not found', Horde_Imap_Client_Exception::DRIVER_NOT_FOUND);
+        $class = 'Horde_Imap_Client_' . strtr(ucfirst(basename($driver)), '-', '_');
+        if (class_exists($class)) {
+            return new $class($params);
         }
-        return new $class($params);
+
+        throw new Horde_Imap_Client_Exception('Driver ' . $driver . ' not found', Horde_Imap_Client_Exception::DRIVER_NOT_FOUND);
     }
 
 }
index dab4348..c0854df 100644 (file)
@@ -1632,7 +1632,7 @@ class Horde_Imap_Client_Cclient extends Horde_Imap_Client_Base
     protected function _getSocket()
     {
         if (!isset($this->_socket)) {
-            $this->_socket = Horde_Imap_Client::getInstance('Socket', $this->_params);
+            $this->_socket = Horde_Imap_Client::factory('Socket', $this->_params);
         }
         return $this->_socket;
     }
index 424ff3a..4d86aef 100644 (file)
@@ -103,7 +103,7 @@ if (@include_once 'Benchmark/Timer.php') {
 // Add an ID field to send to server (ID extension)
 $params['id'] = array('name' => 'Horde_Imap_Client test program');
 
-$imap_client = Horde_Imap_Client::getInstance($driver, $params);
+$imap_client = Horde_Imap_Client::factory($driver, $params);
 if (($driver == 'Cclient_Pop3') ||
     ($driver == 'Socket_Pop3')) {
     $pop3 = true;
index e2423df..06f0b89 100644 (file)
@@ -65,13 +65,14 @@ abstract class Horde_SpellChecker
      *                             instance.
      * @throws Horde_Exception
      */
-    static public function getInstance($driver, $params = array())
+    static public function factory($driver, $params = array())
     {
         $class = 'Horde_SpellChecker_' . Horde_String::ucfirst(basename($driver));
-        if (!class_exists($class)) {
-            throw new Horde_Exception('Driver ' . $driver . ' not found');
+        if (class_exists($class)) {
+            return new $class($params);
         }
-        return new $class($params);
+
+        throw new Horde_Exception('Driver ' . $driver . ' not found');
     }
 
     /**