1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10: class Hermes_Factory_Driver extends Horde_Core_Factory_Injector
11: {
12: 13: 14:
15: private $_instances = array();
16:
17: 18: 19: 20: 21:
22: public function create(Horde_Injector $injector)
23: {
24: $driver = $GLOBALS['conf']['storage']['driver'];
25: $signature = serialize(array($driver, $GLOBALS['conf']['storage']['params']['driverconfig']));
26: if (empty($this->_instances[$signature])) {
27: if ($driver == 'sql' && $GLOBALS['conf']['storage']['params']['driverconfig'] == 'horde') {
28: $params = array('db_adapter' => $injector->getInstance('Horde_Db_Adapter'));
29: } else {
30: throw new Horde_Exception('Using non-global db connection not yet supported.');
31: }
32: $class = 'Hermes_Driver_' . Horde_String::ucfirst($driver);
33: $this->_instances[$signature] = new $class($params);
34: }
35:
36: return $this->_instances[$signature];
37: }
38:
39: }
40: