1: <?php
2: /**
3: * A Horde_Injector:: based Horde_Data:: factory.
4: *
5: * PHP version 5
6: *
7: * @category Horde
8: * @package Core
9: * @author Michael Slusarz <slusarz@horde.org>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Core
12: */
13:
14: /**
15: * A Horde_Injector:: based Horde_Data:: factory.
16: *
17: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @category Horde
23: * @package Core
24: * @author Michael Slusarz <slusarz@horde.org>
25: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
26: * @link http://pear.horde.org/index.php?package=Core
27: */
28: class Horde_Core_Factory_Data extends Horde_Core_Factory_Base
29: {
30: /**
31: * Return the Horde_Data:: instance.
32: *
33: * @param string $driver The driver.
34: * @param string $params Driver parameters.
35: *
36: * @return Horde_Data_Driver The instance.
37: * @throws Horde_Data_Exception
38: */
39: public function create($driver, array $params = array())
40: {
41: $params['browser'] = $this->_injector->getInstance('Horde_Browser');
42: $params['vars'] = Horde_Variables::getDefaultVariables();
43:
44: if (strcasecmp($driver, 'csv') === 0) {
45: $params['charset'] = 'UTF-8';
46: }
47:
48: return Horde_Data::factory($driver, $params);
49: }
50:
51: }
52: