Overview

Packages

  • Kronolith
  • None

Classes

  • Kronolith_Application
  • Kronolith_Block_Month
  • Kronolith_Block_Monthlist
  • Kronolith_Block_Prevmonthlist
  • Kronolith_Block_Summary
  • Kronolith_Factory_Driver
  • Kronolith_Factory_Storage
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: 
 3: class Kronolith_Factory_Storage extends Horde_Core_Factory_Base
 4: {
 5:     /**
 6:      * Instances.
 7:      *
 8:      * @var array
 9:      */
10:     private $_instances = array();
11: 
12:     /**
13:      * Return the driver instance.
14:      *
15:      * @return Kronolith_Storage
16:      * @throws Kronolith_Exception
17:      */
18:     public function create($params = array())
19:     {
20:         if (empty($params['user'])) {
21:             $user = $GLOBALS['registry']->getAuth();
22:         } else {
23:             $user = $params['user'];
24:             unset($params['user']);
25:         }
26: 
27:         if (empty($params['driver'])) {
28:             $driver = Horde_String::ucfirst($GLOBALS['conf']['storage']['driver']);
29:         } else {
30:             $driver = $params['driver'];
31:             unset($params['driver']);
32:         }
33:         $driver = basename($driver);
34:         $class = 'Kronolith_Storage_' . $driver;
35: 
36:         $driver_params =  Horde::getDriverConfig('storage', 'Sql');
37:         if ($driver == 'Sql') {
38:             if ($driver_params != 'Horde') {
39:                 // Custom DB config
40:                 $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('kronolith', Horde::getDriverConfig('storage', 'Sql'));
41:             } else {
42:                 // Horde default DB config
43:                 $params['db'] = $this->_injector->getInstance('Horde_Db_Adapter');
44:             }
45:             $params['table'] = $driver_params['table'];
46:         }
47: 
48:         if (class_exists($class)) {
49:             $driver = new $class($user, $params);
50:         } else {
51:             throw new Kronolith_Exception(sprintf(_("Unable to load the definition of %s."), $class));
52:         }
53: 
54:         try {
55:             $driver->initialize();
56:         } catch (Exception $e) {
57:             $driver = new Kronolith_Storage($params);
58:         }
59: 
60:         return $driver;
61:     }
62: 
63: }
64: 
API documentation generated by ApiGen