Overview

Packages

  • Horde
    • Block
  • None
  • Ulaform

Classes

  • Ulaform
  • Ulaform_Action
  • Ulaform_Action_Mailto
  • Ulaform_Action_Sql
  • Ulaform_Api
  • Ulaform_Driver
  • Ulaform_Driver_Sql
  • Ulaform_Exception
  • Ulaform_Factory_Action
  • Ulaform_Factory_Driver
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Horde_Injector factory to create Ulaform_Driver instances.
 4:  *
 5:  * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * See the enclosed file COPYING for license information (GPL). If you
 8:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 9:  *
10:  * @author  Michael J. Rubinsky <mrubinsk@horde.org>
11:  * @author  Vilius Ĺ umskas <vilius@lnk.lt>
12:  * @package Ulaform
13:  */
14: class Ulaform_Factory_Driver
15: {
16:     /**
17:      * Instances.
18:      *
19:      * @var array
20:      */
21:     private $_instances = array();
22: 
23:     /**
24:      * The injector.
25:      *
26:      * @var Horde_Injector
27:      */
28:     private $_injector;
29: 
30:     /**
31:      * Constructor.
32:      *
33:      * @param Horde_Injector $injector  The injector to use.
34:      */
35:     public function __construct(Horde_Injector $injector)
36:     {
37:         $this->_injector = $injector;
38:     }
39: 
40:     /**
41:      * Return the Ulaform_Driver:: instance.
42:      *
43:      * @param mixed $name  Instance name
44:      *
45:      * @return Ulaform_Driver
46:      * @throws Ulaform_Exception
47:      */
48:     public function create($name = '')
49:     {
50:         if (!isset($this->_instances[$name])) {
51:             $driver = 'Sql';
52:             $params = Horde::getDriverConfig('sql', $driver);
53: 
54:             $class = 'Ulaform_Driver_' . $driver;
55:             if (!class_exists($class)) {
56:                 throw new Ulaform_Exception(sprintf('Unable to load the definition of %s.', $class));
57:             }
58: 
59:             $params = array(
60:                 'db' => $this->_injector->getInstance('Horde_Db_Adapter'),
61:                 'charset' => $params['charset'],
62:             );
63: 
64:             $driver = new $class($params);
65:             $this->_instances[$name] = $driver;
66:         }
67: 
68:         return $this->_instances[$name];
69:     }
70: }
71: 
API documentation generated by ApiGen