From ff024158c54a59ec21602e720043c8be403bf74c Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 24 Jul 2009 22:46:26 -0600 Subject: [PATCH] getInstance() -> factory() --- framework/Ajax/lib/Horde/Ajax/Imple.php | 2 +- framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php | 2 +- framework/Auth/lib/Horde/Auth/Cyrsql.php | 2 +- framework/Auth/lib/Horde/Auth/Cyrus.php | 2 +- framework/Auth/lib/Horde/Auth/Imap.php | 2 +- framework/Imap_Client/lib/Horde/Imap/Client.php | 11 ++++++----- framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php | 2 +- framework/Imap_Client/test/Horde/Imap/test_client.php | 2 +- framework/SpellChecker/lib/Horde/SpellChecker.php | 9 +++++---- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/framework/Ajax/lib/Horde/Ajax/Imple.php b/framework/Ajax/lib/Horde/Ajax/Imple.php index a29044926..dc0bb5058 100644 --- a/framework/Ajax/lib/Horde/Ajax/Imple.php +++ b/framework/Ajax/lib/Horde/Ajax/Imple.php @@ -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; diff --git a/framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php b/framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php index b062ba902..80c57824a 100644 --- a/framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php +++ b/framework/Ajax/lib/Horde/Ajax/Imple/SpellChecker.php @@ -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(); diff --git a/framework/Auth/lib/Horde/Auth/Cyrsql.php b/framework/Auth/lib/Horde/Auth/Cyrsql.php index 39f8ccce5..9821f9b84 100644 --- a/framework/Auth/lib/Horde/Auth/Cyrsql.php +++ b/framework/Auth/lib/Horde/Auth/Cyrsql.php @@ -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); diff --git a/framework/Auth/lib/Horde/Auth/Cyrus.php b/framework/Auth/lib/Horde/Auth/Cyrus.php index b5141c18e..e3b06d81e 100644 --- a/framework/Auth/lib/Horde/Auth/Cyrus.php +++ b/framework/Auth/lib/Horde/Auth/Cyrus.php @@ -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); diff --git a/framework/Auth/lib/Horde/Auth/Imap.php b/framework/Auth/lib/Horde/Auth/Imap.php index 294cf0f0b..181d32b4d 100644 --- a/framework/Auth/lib/Horde/Auth/Imap.php +++ b/framework/Auth/lib/Horde/Auth/Imap.php @@ -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; diff --git a/framework/Imap_Client/lib/Horde/Imap/Client.php b/framework/Imap_Client/lib/Horde/Imap/Client.php index 295f53450..ec7301d7f 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client.php @@ -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); } } diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php index dab434896..c0854df2f 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php @@ -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; } diff --git a/framework/Imap_Client/test/Horde/Imap/test_client.php b/framework/Imap_Client/test/Horde/Imap/test_client.php index 424ff3adb..4d86aef34 100644 --- a/framework/Imap_Client/test/Horde/Imap/test_client.php +++ b/framework/Imap_Client/test/Horde/Imap/test_client.php @@ -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; diff --git a/framework/SpellChecker/lib/Horde/SpellChecker.php b/framework/SpellChecker/lib/Horde/SpellChecker.php index e2423df90..06f0b89a7 100644 --- a/framework/SpellChecker/lib/Horde/SpellChecker.php +++ b/framework/SpellChecker/lib/Horde/SpellChecker.php @@ -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'); } /** -- 2.11.0