Overview

Packages

  • Hylax
  • None

Classes

  • Hylax
  • Hylax_Driver
  • Hylax_Driver_hylafax
  • Hylax_Driver_spandsp
  • Hylax_Image
  • Hylax_SQL_Attributes
  • Hylax_Storage
  • Hylax_Storage_sql
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Hylax_Driver Class
 4:  *
 5:  * Copyright 2003-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  Marko Djukic <marko@oblo.com>
11:  * @package Hylax
12:  */
13: class Hylax_Driver {
14: 
15:     protected $_params;
16: 
17:     public function __construct($params)
18:     {
19:         global $conf;
20: 
21:         $this->_params = $params;
22:     }
23: 
24:     public function getFolder($folder, $path = null)
25:     {
26:         return $this->_getFolder($folder, $path);
27:     }
28: 
29:     /**
30:      * Attempts to return a concrete Hylax_Driver instance based on $driver.
31:      *
32:      * @param string $driver  The type of concrete Hylax_Driver subclass to
33:      *                        return.
34:      * @param array $params   A hash containing any additional configuration or
35:      *                        connection parameters a subclass might need.
36:      *
37:      * @return Hylax_Driver   The newly created concrete Hylax_Driver
38:      *                        instance, or false on error.
39:      */
40:     public function &factory($driver = null, $params = null)
41:     {
42:         if (is_null($driver)) {
43:             $driver = $GLOBALS['conf']['fax']['driver'];
44:         }
45: 
46:         $driver = basename($driver);
47: 
48:         include_once dirname(__FILE__) . '/Driver/' . $driver . '.php';
49:         $class = 'Hylax_Driver_' . $driver;
50:         if (class_exists($class)) {
51:             $hylax = new $class($params);
52:             return $hylax;
53:         }
54: 
55:         throw new Horde_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
56:     }
57: 
58:     /**
59:      * Attempts to return a reference to a concrete Hylax_Driver instance
60:      * based on $driver. It will only create a new instance if no
61:      * Hylax_Driver instance with the same parameters currently exists.
62:      *
63:      * This should be used if multiple storage sources are required.
64:      *
65:      * This method must be invoked as: $var = &Hylax_Driver::singleton()
66:      *
67:      * @param string $driver  The type of concrete Hylax_Driver subclass to
68:      *                        return.
69:      * @param array $params   A hash containing any additional configuration or
70:      *                        connection parameters a subclass might need.
71:      *
72:      * @return mixed  The created concrete Hylax_Driver instance, or false on
73:      *                error.
74:      */
75:     public function &singleton($driver = null, $params = null)
76:     {
77:         static $instances;
78: 
79:         if (is_null($driver)) {
80:             $driver = $GLOBALS['conf']['fax']['driver'];
81:         }
82: 
83:         if (!isset($instances)) {
84:             $instances = array();
85:         }
86:         $signature = serialize(array($driver, $params));
87: 
88:         if (!isset($instances[$signature])) {
89:             $instances[$signature] = &Hylax_Driver::factory($driver, $params);
90:         }
91:         return $instances[$signature];
92:     }
93: 
94: }
95: 
API documentation generated by ApiGen