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_Sentmail 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_Sentmail extends Horde_Core_Factory_Injector
24: {
25: /**
26: * Return the IMP_Sentmail instance.
27: *
28: * @return IMP_Sentmail The singleton instance.
29: * @throws IMP_Exception
30: */
31: public function create(Horde_Injector $injector)
32: {
33: $driver = empty($GLOBALS['conf']['sentmail']['driver'])
34: ? 'null'
35: : $GLOBALS['conf']['sentmail']['driver'];
36: $params = Horde::getDriverConfig('sentmail', $driver);
37:
38: switch (Horde_String::lower($driver)) {
39: case 'nosql':
40: $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('imp', 'sentmail');
41: if ($nosql instanceof Horde_Mongo_Client) {
42: $params['mongo_db'] = $nosql;
43: $driver = 'Mongo';
44: }
45: break;
46:
47: case 'sql':
48: $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', 'sentmail');
49: break;
50:
51: default:
52: $driver = 'null';
53: break;
54: }
55:
56: $class = $this->_getDriverName($driver, 'IMP_Sentmail');
57: return new $class($params);
58: }
59:
60: }
61: