1: <?php
2: /**
3: * Copyright 2013-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 2013-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_Maillog object.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2013-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Factory_Maillog extends Horde_Core_Factory_Injector
24: {
25: /**
26: * Return the IMP_Maillog instance.
27: *
28: * @return IMP_Maillog The singleton instance.
29: */
30: public function create(Horde_Injector $injector)
31: {
32: global $conf, $injector, $registry;
33:
34: $storage = array();
35:
36: if ($injector->getInstance('IMP_Factory_Imap')->create()->isImap()) {
37: $storage[] = new IMP_Maillog_Storage_Mdnsent();
38: }
39:
40: $driver = isset($conf['maillog']['driver'])
41: ? $conf['maillog']['driver']
42: : 'none';
43:
44: switch ($driver) {
45: case 'history':
46: $storage[] = new IMP_Maillog_Storage_History(
47: $injector->getInstance('Horde_History'),
48: $registry->getAuth()
49: );
50: break;
51:
52: case 'none':
53: default:
54: $storage[] = new IMP_Maillog_Storage_Null();
55: break;
56: }
57:
58: return new IMP_Maillog(
59: (count($storage) > 1)
60: ? new IMP_Maillog_Storage_Composite($storage)
61: : reset($storage)
62: );
63: }
64:
65: }
66: