MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
class.phpwsdlhash.php
Ir para a documentação deste ficheiro.
1
<?php
2
3
/*
4
PhpWsdl - Generate WSDL from PHP
5
Copyright (C) 2011 Andreas Zimmermann, wan24.de
6
7
This program is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free Software
9
Foundation; either version 3 of the License, or (at your option) any later
10
version.
11
12
This program is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License along with
17
this program; if not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
if
(basename($_SERVER[
'SCRIPT_FILENAME'
])==basename(__FILE__))
21
exit;
22
23
// This is my solution to swap hash arrays between client/server. The receiver
24
// has to rebuild the hash object in the way his programming language supports
25
// hash arrays. It's just an example solution. To use the types defined here,
26
// you have to include this file in your source using "require". This file has
27
// also to be in the list of files that are parsed by PhpWsdl.
28
//
29
// A sample unserialized PHP hash array (use the "Serialize" method on this):
30
//
31
// Array(
32
// 'a' => 'Value of a',
33
// 'b' => 'Value of b'
34
// )
35
//
36
// The resulting serialized array (return this):
37
//
38
// Array(
39
// PhpWsdlHash(
40
// 'key' => 'a',
41
// 'value' => 'Value of a'
42
// ),
43
// PhpWsdlHash(
44
// 'key' => 'b',
45
// 'value' => 'Value of b'
46
// )
47
// )
48
//
49
// The received serialized array (use the "Deserialize" method on this):
50
//
51
// Array(
52
// object(
53
// 'key' => 'a',
54
// 'value' => 'Value of a'
55
// ),
56
// object(
57
// 'key' => 'b',
58
// 'value' => 'Value of b'
59
// )
60
// )
61
//
62
// The value type must be unique within an hash array. You can return prepared
63
// types like StringHashArray, or you define your own ones. To serialize an
64
// hash array to the target type, use the PhpWsdlHashArrayBuilder class:
65
//
66
// return PhpWsdlHashArrayBuilder::Serialize($yourHashVariable);
67
//
68
// To deserialize an received object:
69
//
70
// $yourHashVariable=PhpWsdlHashArrayBuilder::Deserialize($receivedHashVariable);
71
//
72
// Tip: I prefer converting hashes into an INI formatted string. The string
73
// type is primitive, but it can contain complex information. In nearly every
74
// programming language you can work with the INI format with predefined
75
// classes - or it's very easy to write your own.
76
113
class
PhpWsdlHashArrayBuilder
{
120
public
static
function
Serialize
($hash){
121
if
(is_null($hash))
122
return
null
;
123
$res=Array();
124
$keys=array_keys($hash);
125
$i=-1;
126
$len=
sizeof
($keys);
127
while
(++$i<$len)
128
$res[]=
new
PhpWsdlHash
($keys[$i],$hash[$keys[$i]]);
129
return
$res;
130
}
131
138
public
static
function
Deserialize
($arr){
139
if
(is_null($arr))
140
return
null
;
141
$res=Array();
142
$i=-1;
143
$len=
sizeof
($arr);
144
while
(++$i<$len)
145
$res[$arr[$i]->Key]=$arr[$i]->Value;
146
return
$res;
147
}
148
}
149
155
class
PhpWsdlHash
{
161
public
$Key
;
167
public
$Value
;
168
176
public
function
PhpWsdlHash
($key,$value){
177
self::__construct
($key, $value);
178
}
179
180
public
function
__construct
($key,$value){
181
$this->Key=$key;
182
$this->Value=$value;
183
}
184
}
PhpWsdlHashArrayBuilder
Definição
class.phpwsdlhash.php:113
PhpWsdlHashArrayBuilder\Serialize
static Serialize($hash)
Definição
class.phpwsdlhash.php:120
PhpWsdlHashArrayBuilder\Deserialize
static Deserialize($arr)
Definição
class.phpwsdlhash.php:138
PhpWsdlHash
Definição
class.phpwsdlhash.php:155
PhpWsdlHash\$Value
$Value
Definição
class.phpwsdlhash.php:167
PhpWsdlHash\__construct
__construct($key, $value)
Definição
class.phpwsdlhash.php:180
PhpWsdlHash\$Key
$Key
Definição
class.phpwsdlhash.php:161
PhpWsdlHash\PhpWsdlHash
PhpWsdlHash($key, $value)
Definição
class.phpwsdlhash.php:176
classes
contrib
phpWsdl
class.phpwsdlhash.php
Gerado por
1.10.0