-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathSoapClient.php
executable file
·97 lines (85 loc) · 2.68 KB
/
SoapClient.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
<?php
namespace Phpforce\SoapClient\Soap;
/**
* SOAP client used for the Salesforce API client
*
*/
class SoapClient extends \SoapClient
{
/**
* SOAP types derived from WSDL
*
* @var array
*/
protected $types;
/**
* Retrieve SOAP types from the WSDL and parse them
*
* @return array Array of types and their properties
*/
public function getSoapTypes()
{
if (null === $this->types) {
$soapTypes = $this->__getTypes();
foreach ($soapTypes as $soapType) {
$properties = array();
$lines = explode("\n", $soapType);
if (!preg_match('/struct (.*) {/', $lines[0], $matches)) {
continue;
}
$typeName = $matches[1];
foreach (array_slice($lines, 1) as $line) {
if ($line == '}') {
continue;
}
preg_match('/\s* (.*) (.*);/', $line, $matches);
$properties[$matches[2]] = $matches[1];
}
// Since every object extends sObject, need to append sObject elements to all native and custom objects
if ($typeName !== 'sObject' && array_key_exists('sObject', $this->types)) {
$properties = array_merge($properties, $this->types['sObject']);
}
if ($typeName == 'SingleEmailMessage' && array_key_exists('Email', $this->types)) {
$properties = array_merge($properties, $this->types['Email']);
}
$this->types[$typeName] = $properties;
}
}
return $this->types;
}
/**
* Get a SOAP type’s elements
*
* @param string $type Object name
* @return array Elements for the type
*/
/**
* Get SOAP elements for a complexType
*
* @param string $complexType Name of SOAP complexType
*
* @return array Names of elements and their types
*/
public function getSoapElements($complexType)
{
$types = $this->getSoapTypes();
if (isset($types[$complexType])) {
return $types[$complexType];
}
}
/**
* Get a SOAP type’s element
*
* @param string $complexType Name of SOAP complexType
* @param string $element Name of element belonging to SOAP complexType
*
* @return string
*/
public function getSoapElementType($complexType, $element)
{
$elements = $this->getSoapElements($complexType);
if ($elements && isset($elements[$element])) {
return $elements[$element];
}
}
}