From: Michael M Slusarz Date: Wed, 14 Apr 2010 10:19:25 +0000 (-0600) Subject: Use injector to load IMP_Quota X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f51c01ffa4da0b3d1dc381a0db16356b17fdcf0a;p=horde.git Use injector to load IMP_Quota --- diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 5d430c7e8..d36ba5b18 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -99,6 +99,7 @@ class IMP_Application extends Horde_Registry_Application 'IMP_Folder' => new IMP_Injector_Binder_Folder(), 'IMP_Identity' => new IMP_Injector_Binder_Identity(), 'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(), + 'IMP_Quota' => new IMP_Injector_Binder_Quota(), 'IMP_Sentmail' => new IMP_Injector_Binder_Sentmail() ); diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 34d4964d9..ce7a4e1bc 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -601,9 +601,9 @@ class IMP } try { - $quotaDriver = IMP_Quota::singleton($_SESSION['imp']['imap']['quota']['driver'], isset($_SESSION['imp']['imap']['quota']['params']) ? $_SESSION['imp']['imap']['quota']['params'] : array()); + $quotaDriver = $GLOBALS['injector']->getInstance('IMP_Quota'); $quota = $quotaDriver->getQuota(); - } catch (Horde_Exception $e) { + } catch (Exception $e) { Horde::logMessage($e, 'ERR'); return false; } diff --git a/imp/lib/Injector/Binder/Quota.php b/imp/lib/Injector/Binder/Quota.php new file mode 100644 index 000000000..27a91404a --- /dev/null +++ b/imp/lib/Injector/Binder/Quota.php @@ -0,0 +1,29 @@ + + * @package IMP + */ +class IMP_Injector_Binder_Quota implements Horde_Injector_Binder +{ + /** + */ + public function create(Horde_Injector $injector) + { + return IMP_Quota::factory($_SESSION['imp']['imap']['quota']['driver'], isset($_SESSION['imp']['imap']['quota']['params']) ? $_SESSION['imp']['imap']['quota']['params'] : array()); + } + + /** + */ + public function equals(Horde_Injector_Binder $binder) + { + return false; + } + +} diff --git a/imp/lib/Quota.php b/imp/lib/Quota.php index f588a0b79..9eaae8e32 100644 --- a/imp/lib/Quota.php +++ b/imp/lib/Quota.php @@ -14,13 +14,6 @@ class IMP_Quota { /** - * Singleton instances. - * - * @var array - */ - static protected $_instances = array(); - - /** * Hash containing connection parameters. * * @var array @@ -28,34 +21,6 @@ class IMP_Quota protected $_params = array(); /** - * Attempts to return a reference to a concrete IMP_Quota instance based on - * $driver. - * - * It will only create a new instance if no instance with the same - * parameters currently exists. - * - * This method must be invoked as: $var = IMP_Quota::singleton() - * - * @param string $driver The type of concrete subclass to return. - * @param array $params A hash containing any additional configuration - * or connection parameters a subclass might need. - * - * @return IMP_Quota The concrete instance. - * @throws Horde_Exception - */ - static public function singleton($driver, $params = array()) - { - ksort($params); - $sig = hash('md5', serialize(array($driver, $params))); - - if (!isset(self::$_instances[$sig])) { - self::$_instances[$sig] = self::factory($driver, $params); - } - - return self::$_instances[$sig]; - } - - /** * Attempts to return a concrete instance based on $driver. * * @param string $driver The type of concrete subclass to return. @@ -63,7 +28,7 @@ class IMP_Quota * connection parameters a subclass might need. * * @return IMP_Quota The concrete instance. - * @throws Horde_Exception + * @throws IMP_Exception */ static public function factory($driver, $params = array()) { @@ -74,7 +39,7 @@ class IMP_Quota return new $class($params); } - throw new Horde_Exception('Could not create IMP_Quota instance: ' . $driver); + throw new IMP_Exception('Could not create ' . __CLASS__ . ' instance: ' . $driver); } /**