1: <?php
2: /**
3: * Copyright 2010-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2010-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * A Horde_Injector based factory for the IMP_Quota object.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2010-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Factory_Quota extends Horde_Core_Factory_Injector
24: {
25: /**
26: * Return the IMP_Quota instance.
27: *
28: * @return IMP_Quota The singleton instance.
29: * @throws IMP_Exception
30: */
31: public function create(Horde_Injector $injector)
32: {
33: $imap_ob = $injector->getInstance('IMP_Factory_Imap')->create();
34: $qparams = $imap_ob->config->quota;
35:
36: if (!isset($qparams['driver'])) {
37: throw new IMP_Exception('Quota config missing driver parameter.');
38: }
39: $driver = $qparams['driver'];
40:
41: $params = isset($qparams['params'])
42: ? $qparams['params']
43: : array();
44: $params['username'] = $imap_ob->getParam('username');
45:
46: switch (Horde_String::lower($driver)) {
47: case 'imap':
48: $params['imap_ob'] = $imap_ob;
49: break;
50: }
51:
52: $class = $this->_getDriverName($driver, 'IMP_Quota');
53: return new $class($params);
54: }
55:
56: }
57: