1: <?php
2: 3: 4:
5: class Kronolith_Factory_Driver extends Horde_Core_Factory_Base
6: {
7: 8: 9: 10: 11:
12: private $_instances = array();
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: public function create($driver, $params = array())
24: {
25: $driver = basename($driver);
26: if (!empty($this->_instances[$driver])) {
27: return $this->_instances[$driver];
28: }
29: $key = $driver;
30: $class = 'Kronolith_Driver_' . $driver;
31: if (class_exists($class)) {
32: $driver = new $class($params);
33: try {
34: $driver->initialize();
35: } catch (Exception $e) {
36: $driver = new Kronolith_Driver($params, sprintf(_("The Calendar backend is not currently available: %s"), $e->getMessage()));
37: }
38: } else {
39: $driver = new Kronolith_Driver($params, sprintf(_("Unable to load the definition of %s."), $class));
40: }
41: $this->_instances[$key] = $driver;
42:
43: return $driver;
44: }
45:
46: }
47: