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_Action 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_Action
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_Action:: instance.
42:      *
43:      * @param string $action  The action to use
44:      *
45:      * @return Ulaform_Action
46:      * @throws Ulaform_Exception
47:      */
48:     public function create($action)
49:     {
50:         $action = basename($action);
51:         if (!empty($this->_instances[$action])) {
52:             return $this->_instances[$action];
53:         }
54: 
55:         $class = 'Ulaform_Action_' . $action;
56:         if (!class_exists($class)) {
57:             throw new Ulaform_Exception(sprintf('Unable to load the definition of %s.', $class));
58:         }
59: 
60:         switch ($class) {
61:         case 'Ulaform_Action_Sql':
62:             $params = Horde::getDriverConfig('sql', $action);
63:             $params = array(
64:                 'db' => $this->_injector->getInstance('Horde_Db_Adapter'),
65:                 'charset' => $params['charset'],
66:             );
67:             break;
68:         case 'Ulaform_Action_Mailto':
69:             $params = array();
70:             break;
71:         }
72: 
73:         $this->_instances[$action] = new $class($params);
74: 
75:         return $this->_instances[$action];
76:     }
77: }
78: 
API documentation generated by ApiGen