1 |
joko |
1.1 |
<? |
2 |
|
|
/** |
3 |
joko |
1.3 |
* This file contains the DesignPattern::AdapterProxy class |
4 |
|
|
* |
5 |
|
|
* It combines features from both the standard Proxy |
6 |
|
|
* and the TransparentProxy adding some Adapter features |
7 |
joko |
1.1 |
* |
8 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
9 |
joko |
1.2 |
* @package org.netfrag.glib |
10 |
|
|
* @name DesignPattern::AdapterProxy |
11 |
joko |
1.4 |
* @filesource |
12 |
|
|
* |
13 |
|
|
* |
14 |
|
|
* |
15 |
|
|
* <b>Cvs-Log:</b> |
16 |
joko |
1.1 |
* |
17 |
joko |
1.4 |
* <pre> |
18 |
|
|
* $Id: AdapterProxy.php,v 1.3 2003/03/05 16:10:17 joko Exp $ |
19 |
joko |
1.2 |
* |
20 |
|
|
* $Log: AdapterProxy.php,v $ |
21 |
joko |
1.4 |
* Revision 1.3 2003/03/05 16:10:17 joko |
22 |
|
|
* updated docu (phpDocumentor testing....) |
23 |
|
|
* |
24 |
joko |
1.3 |
* Revision 1.2 2003/03/05 15:41:03 joko |
25 |
|
|
* updated docu (phpDocumentor testing....) |
26 |
|
|
* |
27 |
joko |
1.2 |
* Revision 1.1 2003/03/05 12:07:10 joko |
28 |
|
|
* + initial commit |
29 |
joko |
1.1 |
* |
30 |
|
|
* Revision 1.1 2003/03/03 22:11:08 joko |
31 |
|
|
* + initial commit |
32 |
joko |
1.4 |
* </pre> |
33 |
joko |
1.1 |
* |
34 |
|
|
* |
35 |
|
|
*/ |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
/** |
39 |
joko |
1.4 |
* Make sure we have the required parent class |
40 |
|
|
*/ |
41 |
|
|
loadModule('DesignPattern::TransparentProxy'); |
42 |
|
|
|
43 |
|
|
|
44 |
|
|
/** |
45 |
joko |
1.3 |
* This tries to implement some DesignPattern |
46 |
joko |
1.1 |
* |
47 |
joko |
1.2 |
* |
48 |
joko |
1.1 |
* @author Andreas Motl <andreas.motl@ilo.de> |
49 |
joko |
1.2 |
* @link http://www.netfrag.org/~joko/ |
50 |
|
|
* @copyright (c) 2003 - All Rights reserved. |
51 |
|
|
* @license GNU LGPL (GNU Lesser General Public License) |
52 |
|
|
* @link http://www.gnu.org/licenses/lgpl.txt |
53 |
|
|
* |
54 |
|
|
* @package org.netfrag.glib |
55 |
|
|
* @name DesignPattern::AdapterProxy |
56 |
joko |
1.1 |
* |
57 |
joko |
1.3 |
* @todo Learn TransparentProxy to do procedural calls instead |
58 |
|
|
* of instantiating a component and even less code could be in here..... |
59 |
|
|
* benefit: the TransparentProxy would be become even more powerful |
60 |
|
|
* eeäähhh, to the master Proxy it goes......!!! This one calls the handler(s)! |
61 |
|
|
* |
62 |
|
|
*/ |
63 |
joko |
1.1 |
class DesignPattern_AdapterProxy extends DesignPattern_TransparentProxy { |
64 |
|
|
|
65 |
|
|
var $_adapter; |
66 |
|
|
var $_adapter_module; |
67 |
|
|
var $_adapter_options; |
68 |
|
|
|
69 |
|
|
function &get_adapter() { |
70 |
|
|
return $this->_adapter; |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
function &set_adapter(&$adapter) { |
74 |
|
|
$this->_adapter = &$adapter; |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
// move this code to php::call_func!!! and wrap here!!! |
78 |
|
|
function &create_adapter($m, $f, $a, $options = array()) { |
79 |
|
|
|
80 |
|
|
// load required module |
81 |
|
|
php::loadModule($m); |
82 |
|
|
|
83 |
|
|
// V0: call-handler tests |
84 |
|
|
//$m::$f(); |
85 |
|
|
//$res = call_user_func(array($m, $f)); |
86 |
|
|
//call_user_func("$m::$f"); |
87 |
|
|
//$m->$f(); |
88 |
|
|
|
89 |
|
|
// V1: |
90 |
|
|
//$res = call_user_func( array( $m, $f ) ); |
91 |
|
|
|
92 |
|
|
// V2: |
93 |
|
|
//return call_user_func( array( $m, $f ), $a ); |
94 |
|
|
|
95 |
|
|
if ($options[object]) { |
96 |
|
|
$m = php::mkInstance($m); |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
// V3: |
100 |
|
|
$this->set_adapter( call_user_func( array( &$m, $f ), $a ) ); |
101 |
|
|
return $this->get_adapter(); |
102 |
|
|
|
103 |
|
|
//print Dumper($res); |
104 |
|
|
//exit; |
105 |
|
|
|
106 |
|
|
// FIXME: use TransparentProxy for this! |
107 |
|
|
// V1: |
108 |
|
|
//$this = $res; |
109 |
|
|
// V2: |
110 |
|
|
//$this->make_transparent(); |
111 |
|
|
|
112 |
|
|
//return $res; |
113 |
|
|
|
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
function set_adapter_module($name) { |
117 |
|
|
$this->_adapter_module = $name; |
118 |
|
|
} |
119 |
|
|
function get_adapter_module() { |
120 |
|
|
return $this->_adapter_module; |
121 |
|
|
} |
122 |
|
|
function set_adapter_options(&$options) { |
123 |
|
|
$this->_adapter_options = &$options; |
124 |
|
|
} |
125 |
|
|
function get_adapter_options() { |
126 |
|
|
return $this->_adapter_options; |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
} |
130 |
|
|
|
131 |
|
|
?> |