1: <?php
2: /**
3: * Luxor_Driver:: defines an API for implementing storage backends for Luxor.
4: *
5: * @author Jan Schneider <jan@horde.org>
6: * @since Luxor 0.1
7: * @package Luxor
8: */
9: class Luxor_Driver
10: {
11: /**
12: * Attempts to return a concrete Luxor_Driver instance based on $driver.
13: *
14: * @param string $driver The type of concrete Luxor_Driver subclass
15: * to return. The is based on the storage
16: * driver ($driver). The code is dynamically
17: * included.
18: *
19: * @param array $params (optional) A hash containing any additional
20: * configuration or connection parameters a
21: * subclass might need.
22: *
23: * @return mixed The newly created concrete Luxor_Driver instance, or
24: * false on an error.
25: */
26: function factory($source, $driver = null, $params = null)
27: {
28: if (is_null($driver)) {
29: $driver = $GLOBALS['conf']['storage']['driver'];
30: }
31:
32: $driver = basename($driver);
33:
34: if (is_null($params)) {
35: $params = Horde::getDriverConfig('storage', $driver);
36: }
37:
38: $class = 'Luxor_Driver_' . $driver;
39: if (class_exists($class)) {
40: $luxor = new $class($source, $params);
41: } else {
42: $luxor = false;
43: }
44:
45: return $luxor;
46: }
47: }
48: