1: <?php
2: /**
3: * Copyright 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 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 Mail autoconfiguration object.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Factory_MailAutoconfig
24: extends Horde_Core_Factory_Injector
25: {
26: /**
27: * Return the mail autoconfig instance.
28: *
29: * @return Horde_Mail_Autoconfig The singleton instance.
30: */
31: public function create(Horde_Injector $injector)
32: {
33: /* Need to manually set the drivers, since we should be using Horde
34: * objects for Http_Client and Net_DNS2_Resolver. The return from
35: * getDrivers() is already in priority order, so we don't need to
36: * worry about that. */
37: $drivers = array();
38: foreach (Horde_Mail_Autoconfig::getDrivers() as $val) {
39: $val = clone $val;
40:
41: if (($val instanceof Horde_Mail_Autoconfig_Driver_Guess) ||
42: ($val instanceof Horde_Mail_Autoconfig_Driver_Srv)) {
43: $val->dns = $injector->getInstance('Net_DNS2_Resolver');
44: } elseif ($val instanceof Horde_Mail_Autoconfig_Driver_Thunderbird) {
45: $val->http = $injector->getInstance('Horde_Http_Client');
46: }
47:
48: $drivers[] = $val;
49: }
50:
51: return new Horde_Mail_Autoconfig(array('drivers' => $drivers));
52: }
53:
54: }
55: