'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()
);
}
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;
}
--- /dev/null
+<?php
+/**
+ * Binder for IMP_Quota::.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @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;
+ }
+
+}
class IMP_Quota
{
/**
- * Singleton instances.
- *
- * @var array
- */
- static protected $_instances = array();
-
- /**
* Hash containing connection parameters.
*
* @var array
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.
* 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())
{
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);
}
/**