Overview

Packages

  • Horde
    • Form
    • MIME
      • Viewer
    • Scheduler
  • None
  • Whups
    • UnitTests

Classes

  • Whups_Application
  • Whups_Block_Myqueries
  • Whups_Block_Myrequests
  • Whups_Block_Mytickets
  • Whups_Block_Query
  • Whups_Block_Queuecontents
  • Whups_Block_Queuesummary
  • Whups_Block_Unassigned
  • Whups_Driver_sql
  • Whups_Exception
  • Whups_Factory_Driver
  • Whups_Form_AddListener
  • Whups_Form_DeleteListener
  • Whups_Form_Queue_StepOne
  • Whups_Form_Queue_StepThree
  • Whups_Form_Queue_StepTwo
  • Whups_Form_Renderer_Query
  • Whups_Form_SetTypeStepOne
  • Whups_Form_SetTypeStepTwo
  • Whups_Form_Ticket_Delete
  • Whups_Test_Perms
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Horde_Injector based factory for Kronolith_Driver
 4:  */
 5: class Whups_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 = null, $params = array())
24:     {
25:         if (is_null($driver)) {
26:             $driver = $GLOBALS['conf']['tickets']['driver'];
27:         }
28:         if (!empty($this->_instances[$driver])) {
29:             return $this->_instances[$driver];
30:         }
31:         $driver = basename($driver);
32:         $class = 'Whups_Driver_' . $driver;
33:         if (class_exists($class)) {
34:             if (is_null($params)) {
35:                 $params = Horde::getDriverConfig('tickets', $driver);
36:             }
37:             $this->_instances[$driver] = new $class($params);
38:             switch ($driver) {
39:             case 'Sql':
40:                 $this->_instances[$driver]
41:                     ->setStorage($GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('whups', 'tickets'));
42:             }
43: 
44:             return $this->_instances[$driver];
45:         } else {
46:             throw new Whups_Exception(sprintf('No such backend "%s" found', $driver));
47:         }
48:     }
49: 
50: }
51: 
API documentation generated by ApiGen