This repository has been archived by the owner on Jun 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
WsdlClassFileTpl.php
945 lines (945 loc) · 31.7 KB
/
WsdlClassFileTpl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
<?php
/**
* File for PackageNameWsdlClass to communicate with SOAP service
* @package PackageName
*/
/**
* PackageNameWsdlClass to communicate with SOAP service
* meta_informations
* @package PackageName
*/
class PackageNameWsdlClass extends stdClass implements ArrayAccess,Iterator,Countable
{
/**
* Option key to define WSDL url
* @var string
*/
const WSDL_URL = 'wsdl_url';
/**
* Constant to define the default WSDL URI
* @var string
*/
const VALUE_WSDL_URL = 'wsdl_url_value';
/**
* Option key to define WSDL login
* @var string
*/
const WSDL_LOGIN = 'wsdl_login';
/**
* Option key to define WSDL password
* @deprecated use WSDL_PASSWORD instead
* @var string
*/
const WSDL_PASSWD = 'wsdl_password';
/**
* Option key to define WSDL password
* @var string
*/
const WSDL_PASSWORD = 'wsdl_password';
/**
* Option key to define WSDL trace option
* @var string
*/
const WSDL_TRACE = 'wsdl_trace';
/**
* Option key to define WSDL exceptions
* @deprecated use WSDL_EXCEPTIONS instead
* @var string
*/
const WSDL_EXCPTS = 'wsdl_exceptions';
/**
* Option key to define WSDL exceptions
* @var string
*/
const WSDL_EXCEPTIONS = 'wsdl_exceptions';
/**
* Option key to define WSDL cache_wsdl
* @var string
*/
const WSDL_CACHE_WSDL = 'wsdl_cache_wsdl';
/**
* Option key to define WSDL stream_context
* @var string
*/
const WSDL_STREAM_CONTEXT = 'wsdl_stream_context';
/**
* Option key to define WSDL soap_version
* @var string
*/
const WSDL_SOAP_VERSION = 'wsdl_soap_version';
/**
* Option key to define WSDL compression
* @var string
*/
const WSDL_COMPRESSION = 'wsdl_compression';
/**
* Option key to define WSDL encoding
* @var string
*/
const WSDL_ENCODING = 'wsdl_encoding';
/**
* Option key to define WSDL connection_timeout
* @var string
*/
const WSDL_CONNECTION_TIMEOUT = 'wsdl_connection_timeout';
/**
* Option key to define WSDL typemap
* @var string
*/
const WSDL_TYPEMAP = 'wsdl_typemap';
/**
* Option key to define WSDL user_agent
* @var string
*/
const WSDL_USER_AGENT = 'wsdl_user_agent';
/**
* Option key to define WSDL features
* @var string
*/
const WSDL_FEATURES = 'wsdl_features';
/**
* Option key to define WSDL keep_alive
* @var string
*/
const WSDL_KEEP_ALIVE = 'wsdl_keep_alive';
/**
* Option key to define WSDL proxy_host
* @var string
*/
const WSDL_PROXY_HOST = 'wsdl_proxy_host';
/**
* Option key to define WSDL proxy_port
* @var string
*/
const WSDL_PROXY_PORT = 'wsdl_proxy_port';
/**
* Option key to define WSDL proxy_login
* @var string
*/
const WSDL_PROXY_LOGIN = 'wsdl_proxy_login';
/**
* Option key to define WSDL proxy_password
* @var string
*/
const WSDL_PROXY_PASSWORD = 'wsdl_proxy_password';
/**
* Option key to define WSDL local_cert
* @var string
*/
const WSDL_LOCAL_CERT = 'wsdl_local_cert';
/**
* Option key to define WSDL passphrase
* @var string
*/
const WSDL_PASSPHRASE = 'wsdl_passphrase';
/**
* Option key to define WSDL authentication
* @var string
*/
const WSDL_AUTHENTICATION = 'wsdl_authentication';
/**
* Option key to define WSDL ssl_method
* @var string
*/
const WSDL_SSL_METHOD = 'wsdl_ssl_method';
/**
* Soapclient called to communicate with the actual SOAP Service
* @var SoapClient
*/
private static $soapClient;
/**
* Contains Soap call result
* @var mixed
*/
private $result;
/**
* Contains last errors
* @var array
*/
private $lastError;
/**
* Array that contains values when only one parameter is set when calling __construct method
* @var array
*/
private $internArrayToIterate;
/**
* Bool that tells if array is set or not
* @var bool
*/
private $internArrayToIterateIsArray;
/**
* Items index browser
* @var int
*/
private $internArrayToIterateOffset;
/**
* Constructor
* @uses PackageNameWsdlClass::setLastError()
* @uses PackageNameWsdlClass::initSoapClient()
* @uses PackageNameWsdlClass::initInternArrayToIterate()
* @uses PackageNameWsdlClass::_set()
* @param array $_arrayOfValues SoapClient options or object attribute values
* @param bool $_resetSoapClient allows to disable the SoapClient redefinition
* @return PackageNameWsdlClass
*/
public function __construct($_arrayOfValues = array(),$_resetSoapClient = true)
{
$this->setLastError(array());
/**
* Init soap Client
* Set default values
*/
if($_resetSoapClient)
$this->initSoapClient($_arrayOfValues);
/**
* Init array of values if set
*/
$this->initInternArrayToIterate($_arrayOfValues);
/**
* Generic set methods
*/
if(is_array($_arrayOfValues) && count($_arrayOfValues))
{
foreach($_arrayOfValues as $name=>$value)
$this->_set($name,$value);
}
}
/**
* Generic method called when an object has been exported with var_export() functions
* It allows to return an object instantiated with the values
* @uses PackageNameWsdlClass::_set()
* @param array $_array the exported values
* @param string $_className optional (used by inherited classes in order to always call this method)
* @return PackageNameWsdlClass|null
*/
public static function __set_state(array $_array,$_className = __CLASS__)
{
if(class_exists($_className))
{
$object = @new $_className();
if(is_object($object) && is_subclass_of($object,'PackageNameWsdlClass'))
{
foreach($_array as $name=>$value)
$object->_set($name,$value);
}
return $object;
}
else
return null;
}
/**
* Static method getting current SoapClient
* @return SoapClient
*/
public static function getSoapClient()
{
return self::$soapClient;
}
/**
* Static method setting current SoapClient
* @param SoapClient $_soapClient
* @return SoapClient
*/
protected static function setSoapClient(SoapClient $_soapClient)
{
return (self::$soapClient = $_soapClient);
}
/**
* Method initiating SoapClient
* @uses PackageNameClassMap::classMap()
* @uses PackageNameWsdlClass::getDefaultWsdlOptions()
* @uses PackageNameWsdlClass::getSoapClientClassName()
* @uses PackageNameWsdlClass::setSoapClient()
* @param array $_wsdlOptions WSDL options
* @return void
*/
public function initSoapClient($_wsdlOptions)
{
if(class_exists('PackageNameClassMap',true))
{
$wsdlOptions = array();
$wsdlOptions['classmap'] = PackageNameClassMap::classMap();
$defaultWsdlOptions = self::getDefaultWsdlOptions();
foreach($defaultWsdlOptions as $optioName=>$optionValue)
{
if(array_key_exists($optioName,$_wsdlOptions) && !empty($_wsdlOptions[$optioName]))
$wsdlOptions[str_replace('wsdl_','',$optioName)] = $_wsdlOptions[$optioName];
elseif(!empty($optionValue))
$wsdlOptions[str_replace('wsdl_','',$optioName)] = $optionValue;
}
if(array_key_exists(str_replace('wsdl_','',self::WSDL_URL),$wsdlOptions))
{
$wsdlUrl = $wsdlOptions[str_replace('wsdl_','',self::WSDL_URL)];
unset($wsdlOptions[str_replace('wsdl_','',self::WSDL_URL)]);
$soapClientClassName = self::getSoapClientClassName();
self::setSoapClient(new $soapClientClassName($wsdlUrl,$wsdlOptions));
}
}
}
/**
* Returns the SoapClient class name to use to create the instance of the SoapClient.
* The SoapClient class is determined based on the package name.
* If a class is named as {PackageName}SoapClient, then this is the class that will be used.
* Be sure that this class inherits from the native PHP SoapClient class and this class has been loaded or can be loaded.
* The goal is to allow the override of the SoapClient without having to modify this generated class.
* Then the overridding SoapClient class can override for example the SoapClient::__doRequest() method if it is needed.
* @return string
*/
public static function getSoapClientClassName()
{
if(class_exists('PackageNameSoapClient') && is_subclass_of('PackageNameSoapClient','SoapClient'))
return 'PackageNameSoapClient';
else
return 'SoapClient';
}
/**
* Method returning all default options values
* @uses PackageNameWsdlClass::WSDL_CACHE_WSDL
* @uses PackageNameWsdlClass::WSDL_COMPRESSION
* @uses PackageNameWsdlClass::WSDL_CONNECTION_TIMEOUT
* @uses PackageNameWsdlClass::WSDL_ENCODING
* @uses PackageNameWsdlClass::WSDL_EXCEPTIONS
* @uses PackageNameWsdlClass::WSDL_FEATURES
* @uses PackageNameWsdlClass::WSDL_LOGIN
* @uses PackageNameWsdlClass::WSDL_PASSWORD
* @uses PackageNameWsdlClass::WSDL_SOAP_VERSION
* @uses PackageNameWsdlClass::WSDL_STREAM_CONTEXT
* @uses PackageNameWsdlClass::WSDL_TRACE
* @uses PackageNameWsdlClass::WSDL_TYPEMAP
* @uses PackageNameWsdlClass::WSDL_URL
* @uses PackageNameWsdlClass::VALUE_WSDL_URL
* @uses PackageNameWsdlClass::WSDL_USER_AGENT
* @uses PackageNameWsdlClass::WSDL_PROXY_HOST
* @uses PackageNameWsdlClass::WSDL_PROXY_PORT
* @uses PackageNameWsdlClass::WSDL_PROXY_LOGIN
* @uses PackageNameWsdlClass::WSDL_PROXY_PASSWORD
* @uses PackageNameWsdlClass::WSDL_LOCAL_CERT
* @uses PackageNameWsdlClass::WSDL_PASSPHRASE
* @uses PackageNameWsdlClass::WSDL_AUTHENTICATION
* @uses PackageNameWsdlClass::WSDL_SSL_METHOD
* @uses SOAP_SINGLE_ELEMENT_ARRAYS
* @uses SOAP_USE_XSI_ARRAY_TYPE
* @return array
*/
public static function getDefaultWsdlOptions()
{
return array(
self::WSDL_CACHE_WSDL=>WSDL_CACHE_NONE,
self::WSDL_COMPRESSION=>null,
self::WSDL_CONNECTION_TIMEOUT=>null,
self::WSDL_ENCODING=>null,
self::WSDL_EXCEPTIONS=>true,
self::WSDL_FEATURES=>SOAP_SINGLE_ELEMENT_ARRAYS | SOAP_USE_XSI_ARRAY_TYPE,
self::WSDL_LOGIN=>null,
self::WSDL_PASSWORD=>null,
self::WSDL_SOAP_VERSION=>null,
self::WSDL_STREAM_CONTEXT=>null,
self::WSDL_TRACE=>true,
self::WSDL_TYPEMAP=>null,
self::WSDL_URL=>self::VALUE_WSDL_URL,
self::WSDL_USER_AGENT=>null,
self::WSDL_PROXY_HOST=>null,
self::WSDL_PROXY_PORT=>null,
self::WSDL_PROXY_LOGIN=>null,
self::WSDL_PROXY_PASSWORD=>null,
self::WSDL_LOCAL_CERT=>null,
self::WSDL_PASSPHRASE=>null,
self::WSDL_AUTHENTICATION=>null,
self::WSDL_SSL_METHOD=>null);
}
/**
* Allows to set the SoapClient location to call
* @uses PackageNameWsdlClass::getSoapClient()
* @uses SoapClient::__setLocation()
* @param string $_location
*/
public function setLocation($_location)
{
return self::getSoapClient()?self::getSoapClient()->__setLocation($_location):false;
}
/**
* Returns the last request content as a DOMDocument or as a formated XML String
* @see SoapClient::__getLastRequest()
* @uses PackageNameWsdlClass::getSoapClient()
* @uses PackageNameWsdlClass::getFormatedXml()
* @uses SoapClient::__getLastRequest()
* @param bool $_asDomDocument
* @return DOMDocument|string
*/
public function getLastRequest($_asDomDocument = false)
{
if(self::getSoapClient())
return self::getFormatedXml(self::getSoapClient()->__getLastRequest(),$_asDomDocument);
return null;
}
/**
* Returns the last response content as a DOMDocument or as a formated XML String
* @see SoapClient::__getLastResponse()
* @uses PackageNameWsdlClass::getSoapClient()
* @uses PackageNameWsdlClass::getFormatedXml()
* @uses SoapClient::__getLastResponse()
* @param bool $_asDomDocument
* @return DOMDocument|string
*/
public function getLastResponse($_asDomDocument = false)
{
if(self::getSoapClient())
return self::getFormatedXml(self::getSoapClient()->__getLastResponse(),$_asDomDocument);
return null;
}
/**
* Returns the last request headers used by the SoapClient object as the original value or an array
* @see SoapClient::__getLastRequestHeaders()
* @uses PackageNameWsdlClass::getSoapClient()
* @uses PackageNameWsdlClass::convertStringHeadersToArray()
* @uses SoapClient::__getLastRequestHeaders()
* @param bool $_asArray allows to get the headers in an associative array
* @return null|string|array
*/
public function getLastRequestHeaders($_asArray = false)
{
$headers = self::getSoapClient()?self::getSoapClient()->__getLastRequestHeaders():null;
if(is_string($headers) && $_asArray)
return self::convertStringHeadersToArray($headers);
return $headers;
}
/**
* Returns the last response headers used by the SoapClient object as the original value or an array
* @see SoapClient::__getLastResponseHeaders()
* @uses PackageNameWsdlClass::getSoapClient()
* @uses PackageNameWsdlClass::convertStringHeadersToArray()
* @uses SoapClient::__getLastRequestHeaders()
* @param bool $_asArray allows to get the headers in an associative array
* @return null|string|array
*/
public function getLastResponseHeaders($_asArray = false)
{
$headers = self::getSoapClient()?self::getSoapClient()->__getLastResponseHeaders():null;
if(is_string($headers) && $_asArray)
return self::convertStringHeadersToArray($headers);
return $headers;
}
/**
* Returns a XML string content as a DOMDocument or as a formated XML string
* @uses DOMDocument::loadXML()
* @uses DOMDocument::saveXML()
* @param string $_string
* @param bool $_asDomDocument
* @return DOMDocument|string|null
*/
public static function getFormatedXml($_string,$_asDomDocument = false)
{
if(!empty($_string) && class_exists('DOMDocument'))
{
$dom = new DOMDocument('1.0','UTF-8');
$dom->formatOutput = true;
$dom->preserveWhiteSpace = false;
$dom->resolveExternals = false;
$dom->substituteEntities = false;
$dom->validateOnParse = false;
if($dom->loadXML($_string))
return $_asDomDocument?$dom:$dom->saveXML();
}
return $_asDomDocument?null:$_string;
}
/**
* Returns an associative array between the headers name and their respective values
* @param string $_headers
* @return array
*/
public static function convertStringHeadersToArray($_headers)
{
$lines = explode("\r\n",$_headers);
$headers = array();
foreach($lines as $line)
{
if(strpos($line,':'))
{
$headerParts = explode(':',$line);
$headers[$headerParts[0]] = trim(implode(':',array_slice($headerParts,1)));
}
}
return $headers;
}
/**
* Sets a SoapHeader to send
* For more information, please read the online documentation on {@link http://www.php.net/manual/en/class.soapheader.php}
* @uses PackageNameWsdlClass::getSoapClient()
* @uses SoapClient::__setSoapheaders()
* @param string $_nameSpace SoapHeader namespace
* @param string $_name SoapHeader name
* @param mixed $_data SoapHeader data
* @param bool $_mustUnderstand
* @param string $_actor
* @return bool true|false
*/
public function setSoapHeader($_nameSpace,$_name,$_data,$_mustUnderstand = false,$_actor = null)
{
if(self::getSoapClient())
{
$defaultHeaders = (isset(self::getSoapClient()->__default_headers) && is_array(self::getSoapClient()->__default_headers))?self::getSoapClient()->__default_headers:array();
foreach($defaultHeaders as $index=>$soapheader)
{
if($soapheader->name == $_name)
{
unset($defaultHeaders[$index]);
break;
}
}
self::getSoapClient()->__setSoapheaders(null);
if(!empty($_actor))
array_push($defaultHeaders,new SoapHeader($_nameSpace,$_name,$_data,$_mustUnderstand,$_actor));
else
array_push($defaultHeaders,new SoapHeader($_nameSpace,$_name,$_data,$_mustUnderstand));
return self::getSoapClient()->__setSoapheaders($defaultHeaders);
}
else
return false;
}
/**
* Sets the SoapClient Stream context HTTP Header name according to its value
* If a context already exists, it tries to modify it
* It the context does not exist, it then creates it with the header name and its value
* @uses PackageNameWsdlClass::getSoapClient()
* @param string $_headerName
* @param mixed $_headerValue
* @return bool true|false
*/
public function setHttpHeader($_headerName,$_headerValue)
{
if(self::getSoapClient() && !empty($_headerName))
{
$streamContext = (isset(self::getSoapClient()->_stream_context) && is_resource(self::getSoapClient()->_stream_context))?self::getSoapClient()->_stream_context:null;
if(!is_resource($streamContext))
{
$options = array();
$options['http'] = array();
$options['http']['header'] = '';
}
else
{
$options = stream_context_get_options($streamContext);
if(is_array($options))
{
if(!array_key_exists('http',$options) || !is_array($options['http']))
{
$options['http'] = array();
$options['http']['header'] = '';
}
elseif(!array_key_exists('header',$options['http']))
$options['http']['header'] = '';
}
else
{
$options = array();
$options['http'] = array();
$options['http']['header'] = '';
}
}
if(count($options) && array_key_exists('http',$options) && is_array($options['http']) && array_key_exists('header',$options['http']) && is_string($options['http']['header']))
{
$lines = explode("\r\n",$options['http']['header']);
/**
* Ensure there is only one header entry for this header name
*/
$newLines = array();
foreach($lines as $line)
{
if(!empty($line) && strpos($line,$_headerName) === false)
array_push($newLines,$line);
}
/**
* Add new header entry
*/
array_push($newLines,"$_headerName: $_headerValue");
/**
* Set the context http header option
*/
$options['http']['header'] = implode("\r\n",$newLines);
/**
* Create context if it does not exist
*/
if(!is_resource($streamContext))
return (self::getSoapClient()->_stream_context = stream_context_create($options))?true:false;
/**
* Set the new context http header option
*/
else
return stream_context_set_option(self::getSoapClient()->_stream_context,'http','header',$options['http']['header']);
}
else
return false;
}
else
return false;
}
/**
* Method alias to count
* @uses PackageNameWsdlClass::count()
* @return int
*/
public function length()
{
return $this->count();
}
/**
* Method returning item length, alias to length
* @uses PackageNameWsdlClass::getInternArrayToIterate()
* @uses PackageNameWsdlClass::getInternArrayToIterateIsArray()
* @return int
*/
public function count()
{
return $this->getInternArrayToIterateIsArray()?count($this->getInternArrayToIterate()):-1;
}
/**
* Method returning the current element
* @uses PackageNameWsdlClass::offsetGet()
* @return mixed
*/
public function current()
{
return $this->offsetGet($this->internArrayToIterateOffset);
}
/**
* Method moving the current position to the next element
* @uses PackageNameWsdlClass::getInternArrayToIterateOffset()
* @uses PackageNameWsdlClass::setInternArrayToIterateOffset()
* @return int
*/
public function next()
{
return $this->setInternArrayToIterateOffset($this->getInternArrayToIterateOffset() + 1);
}
/**
* Method resetting itemOffset
* @uses PackageNameWsdlClass::setInternArrayToIterateOffset()
* @return int
*/
public function rewind()
{
return $this->setInternArrayToIterateOffset(0);
}
/**
* Method checking if current itemOffset points to an existing item
* @uses PackageNameWsdlClass::getInternArrayToIterateOffset()
* @uses PackageNameWsdlClass::offsetExists()
* @return bool true|false
*/
public function valid()
{
return $this->offsetExists($this->getInternArrayToIterateOffset());
}
/**
* Method returning current itemOffset value, alias to getInternArrayToIterateOffset
* @uses PackageNameWsdlClass::getInternArrayToIterateOffset()
* @return int
*/
public function key()
{
return $this->getInternArrayToIterateOffset();
}
/**
* Method alias to offsetGet
* @see PackageNameWsdlClass::offsetGet()
* @uses PackageNameWsdlClass::offsetGet()
* @param int $_index
* @return mixed
*/
public function item($_index)
{
return $this->offsetGet($_index);
}
/**
* Default method adding item to array
* @uses PackageNameWsdlClass::getAttributeName()
* @uses PackageNameWsdlClass::__toString()
* @uses PackageNameWsdlClass::_set()
* @uses PackageNameWsdlClass::_get()
* @uses PackageNameWsdlClass::setInternArrayToIterate()
* @uses PackageNameWsdlClass::setInternArrayToIterateIsArray()
* @uses PackageNameWsdlClass::setInternArrayToIterateOffset()
* @param mixed $_item value
* @return bool true|false
*/
public function add($_item)
{
if($this->getAttributeName() != '' && stripos($this->__toString(),'array') !== false)
{
/**
* init array
*/
if(!is_array($this->_get($this->getAttributeName())))
$this->_set($this->getAttributeName(),array());
/**
* current array
*/
$currentArray = $this->_get($this->getAttributeName());
array_push($currentArray,$_item);
$this->_set($this->getAttributeName(),$currentArray);
$this->setInternArrayToIterate($currentArray);
$this->setInternArrayToIterateIsArray(true);
$this->setInternArrayToIterateOffset(0);
return true;
}
return false;
}
/**
* Method to call when sending data to request for *array* type class
* @uses PackageNameWsdlClass::getAttributeName()
* @uses PackageNameWsdlClass::__toString()
* @uses PackageNameWsdlClass::_get()
* @return mixed
*/
public function toSend()
{
if($this->getAttributeName() != '' && stripos($this->__toString(),'array') !== false)
return $this->_get($this->getAttributeName());
else
return null;
}
/**
* Method returning the first item
* @uses PackageNameWsdlClass::item()
* @return mixed
*/
public function first()
{
return $this->item(0);
}
/**
* Method returning the last item
* @uses PackageNameWsdlClass::item()
* @uses PackageNameWsdlClass::length()
* @return mixed
*/
public function last()
{
return $this->item($this->length() - 1);
}
/**
* Method testing index in item
* @uses PackageNameWsdlClass::getInternArrayToIterateIsArray()
* @uses PackageNameWsdlClass::getInternArrayToIterate()
* @param int $_offset
* @return bool true|false
*/
public function offsetExists($_offset)
{
return ($this->getInternArrayToIterateIsArray() && array_key_exists($_offset,$this->getInternArrayToIterate()));
}
/**
* Method returning the item at "index" value
* @uses PackageNameWsdlClass::offsetExists()
* @param int $_offset
* @return mixed
*/
public function offsetGet($_offset)
{
return $this->offsetExists($_offset)?$this->internArrayToIterate[$_offset]:null;
}
/**
* Method useless but necessarly overridden, can't set
* @param mixed $_offset
* @param mixed $_value
* @return null
*/
public function offsetSet($_offset,$_value)
{
return null;
}
/**
* Method useless but necessarly overridden, can't unset
* @param mixed $_offset
* @return null
*/
public function offsetUnset($_offset)
{
return null;
}
/**
* Method returning current result from Soap call
* @return mixed
*/
public function getResult()
{
return $this->result;
}
/**
* Method setting current result from Soap call
* @param mixed $_result
* @return mixed
*/
protected function setResult($_result)
{
return ($this->result = $_result);
}
/**
* Method returning last errors occured during the calls
* @return array
*/
public function getLastError()
{
return $this->lastError;
}
/**
* Method setting last errors occured during the calls
* @param array $_lastError
* @return array
*/
private function setLastError($_lastError)
{
return ($this->lastError = $_lastError);
}
/**
* Method saving the last error returned by the SoapClient
* @param string $_methoName the method called when the error occurred
* @param SoapFault $_soapFault l'objet de l'erreur
* @return bool true|false
*/
protected function saveLastError($_methoName,SoapFault $_soapFault)
{
return ($this->lastError[$_methoName] = $_soapFault);
}
/**
* Method getting the last error for a certain method
* @param string $_methoName method name to get error from
* @return SoapFault|null
*/
public function getLastErrorForMethod($_methoName)
{
return (is_array($this->lastError) && array_key_exists($_methoName,$this->lastError))?$this->lastError[$_methoName]:null;
}
/**
* Method returning intern array to iterate trough
* @return array
*/
public function getInternArrayToIterate()
{
return $this->internArrayToIterate;
}
/**
* Method setting intern array to iterate trough
* @param array $_internArrayToIterate
* @return array
*/
public function setInternArrayToIterate($_internArrayToIterate)
{
return ($this->internArrayToIterate = $_internArrayToIterate);
}
/**
* Method returnint intern array index when iterating trough
* @return int
*/
public function getInternArrayToIterateOffset()
{
return $this->internArrayToIterateOffset;
}
/**
* Method initiating internArrayToIterate
* @uses PackageNameWsdlClass::setInternArrayToIterate()
* @uses PackageNameWsdlClass::setInternArrayToIterateOffset()
* @uses PackageNameWsdlClass::setInternArrayToIterateIsArray()
* @uses PackageNameWsdlClass::getAttributeName()
* @uses PackageNameWsdlClass::initInternArrayToIterate()
* @uses PackageNameWsdlClass::__toString()
* @param array $_array the array to iterate trough
* @param bool $_internCall indicates that methods is calling itself
* @return void
*/
public function initInternArrayToIterate($_array = array(),$_internCall = false)
{
if(stripos($this->__toString(),'array') !== false)
{
if(is_array($_array) && count($_array))
{
$this->setInternArrayToIterate($_array);
$this->setInternArrayToIterateOffset(0);
$this->setInternArrayToIterateIsArray(true);
}
elseif(!$_internCall && $this->getAttributeName() != '' && property_exists($this->__toString(),$this->getAttributeName()))
$this->initInternArrayToIterate($this->_get($this->getAttributeName()),true);
}
}
/**
* Method setting intern array offset when iterating trough
* @param int $_internArrayToIterateOffset
* @return int
*/
public function setInternArrayToIterateOffset($_internArrayToIterateOffset)
{
return ($this->internArrayToIterateOffset = $_internArrayToIterateOffset);
}
/**
* Method returning true if intern array is an actual array
* @return bool true|false
*/
public function getInternArrayToIterateIsArray()
{
return $this->internArrayToIterateIsArray;
}
/**
* Method setting if intern array is an actual array
* @param bool $_internArrayToIterateIsArray
* @return bool true|false
*/
public function setInternArrayToIterateIsArray($_internArrayToIterateIsArray = false)
{
return ($this->internArrayToIterateIsArray = $_internArrayToIterateIsArray);
}
/**
* Generic method setting value
* @param string $_name property name to set
* @param mixed $_value property value to use
* @return bool
*/
public function _set($_name,$_value)
{
$setMethod = 'set' . ucfirst($_name);
if(method_exists($this,$setMethod))
{
$this->$setMethod($_value);
return true;
}
else
return false;
}
/**
* Generic method getting value
* @param string $_name property name to get
* @return mixed
*/
public function _get($_name)
{
$getMethod = 'get' . ucfirst($_name);
if(method_exists($this,$getMethod))
return $this->$getMethod();
else
return false;
}
/**
* Method returning alone attribute name when class is *array* type
* @return string
*/
public function getAttributeName()
{
return '';
}
/**
* Generic method telling if current value is valid according to the attribute setted with the current value
* @param mixed $_value the value to test
* @return bool true|false
*/
public static function valueIsValid($_value)
{
return true;
}
/**
* Method returning actual class name
* @return string __CLASS__
*/
public function __toString()
{
return __CLASS__;
}
}