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