1: <?php
2: /**
3: * A Horde_Injector based factory for the IMP_Sentmail object.
4: *
5: * PHP version 5
6: *
7: * @author Michael Slusarz <slusarz@horde.org>
8: * @category Horde
9: * @license http://www.horde.org/licenses/gpl GPL
10: * @link http://pear.horde.org/index.php?package=IMP
11: * @package IMP
12: */
13:
14: /**
15: * A Horde_Injector based factory for the IMP_Sentmail object.
16: *
17: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (GPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/gpl.
21: *
22: * @author Michael Slusarz <slusarz@horde.org>
23: * @category Horde
24: * @license http://www.horde.org/licenses/gpl GPL
25: * @link http://pear.horde.org/index.php?package=IMP
26: * @package IMP
27: */
28: class IMP_Factory_Sentmail extends Horde_Core_Factory_Injector
29: {
30: /**
31: * Return the IMP_Sentmail instance.
32: *
33: * @return IMP_Sentmail The singleton instance.
34: */
35: public function create(Horde_Injector $injector)
36: {
37: $driver = empty($GLOBALS['conf']['sentmail']['driver'])
38: ? 'Null'
39: : $GLOBALS['conf']['sentmail']['driver'];
40: $params = Horde::getDriverConfig('sentmail', $driver);
41:
42: if (strcasecmp($driver, 'Sql') === 0) {
43: $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', 'sentmail');
44: } elseif (strcasecmp($driver, 'None') === 0) {
45: $driver = 'Null';
46: }
47:
48: return IMP_Sentmail::factory($driver, $params);
49: }
50:
51: }
52: