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:  * Horde_Injector based factory for Kronolith_Driver
 4:  */
 5: class Kronolith_Factory_Driver extends Horde_Core_Factory_Base
 6: {
 7:     /**
 8:      * Instances.
 9:      *
10:      * @var array
11:      */
12:     private $_instances = array();
13: 
14:     /**
15:      * Return the driver instance.
16:      *
17:      * @param string $driver  The storage backend to use
18:      * @param array $params   Driver params
19:      *
20:      * @return Kronolith_Driver
21:      * @throws Kronolith_Exception
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: 
API documentation generated by ApiGen