Total Complexity | 20 |
Total Lines | 162 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class MySalesforcePartnerApi extends Partner |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * turns key value pairs into string |
||
13 | * @param array $array [description] |
||
14 | * @return string |
||
15 | */ |
||
16 | public static function array2sql($array, $glue = ' AND ') : string |
||
17 | { |
||
18 | if(count($array) === 0) { |
||
19 | user_error('must have at least one entry'); |
||
20 | } |
||
21 | $inner = []; |
||
22 | foreach($array as $field => $value) { |
||
23 | $inner[$field] = $field.' = '.Convert::raw2sql($value, true); |
||
1 ignored issue
–
show
|
|||
24 | } |
||
25 | |||
26 | return implode($glue, $inner); |
||
27 | } |
||
28 | |||
29 | |||
30 | public function debug($response = null) |
||
31 | { |
||
32 | $this->debugShowRequest(); |
||
33 | $this->debugShowResponse($response); |
||
34 | } |
||
35 | |||
36 | protected function debugShowRequest() |
||
37 | { |
||
38 | $this->debugOutput(' |
||
39 | <h2>Request</h2> |
||
40 | <pre> |
||
41 | '); |
||
42 | $this->debugOutput($this->debugLastRequest(), true); |
||
43 | $this->debugOutput(' |
||
44 | </pre> |
||
45 | '); |
||
46 | } |
||
47 | |||
48 | |||
49 | protected function debugShowResponse($response) |
||
50 | { |
||
51 | $this->debugOutput(' |
||
52 | <h2>Response</h2> |
||
53 | <pre> |
||
54 | '); |
||
55 | $this->debugOutput($response); |
||
56 | $this->debugOutput(' |
||
57 | </pre> |
||
58 | '); |
||
59 | } |
||
60 | |||
61 | protected function debugLastRequest() |
||
62 | { |
||
63 | $xml = $this->getLastRequest(); |
||
64 | |||
65 | if (! $xml) { |
||
66 | return null; |
||
67 | } |
||
68 | $domxml = new \DOMDocument('1.0'); |
||
69 | $domxml->preserveWhiteSpace = false; |
||
70 | $domxml->formatOutput = true; |
||
71 | /* @var $xml SimpleXMLElement */ |
||
72 | $domxml->loadXML($xml); |
||
73 | echo $domxml->saveXML(); |
||
74 | } |
||
75 | |||
76 | |||
77 | |||
78 | protected function debugOutput($html, $escape = false) |
||
79 | { |
||
80 | if (! is_string($html)) { |
||
81 | $html = print_r($html, 1); |
||
82 | } |
||
83 | if ($this->isCli()) { |
||
84 | echo "\n"; |
||
85 | } elseif ($escape) { |
||
86 | $html = htmlentities($html); |
||
87 | } |
||
88 | |||
89 | echo $html; |
||
90 | } |
||
91 | |||
92 | protected function isCli() |
||
95 | } |
||
96 | |||
97 | |||
98 | ##################################### |
||
99 | # overriding parent class to fix bugs |
||
100 | # in the parent class. |
||
101 | ##################################### |
||
102 | /** |
||
103 | * Adds one or more new individual objects to your organization's data. |
||
104 | * |
||
105 | * @param SObject[] $sObjects Array of one or more sObjects (up to 200) to create. |
||
106 | * @param null|string $type Unused |
||
107 | * |
||
108 | * @return SaveResult |
||
109 | */ |
||
110 | public function create($sObjects, $type = null) |
||
111 | { |
||
112 | foreach ($sObjects as $sObject) { |
||
113 | if (property_exists($sObject, 'fields')) { |
||
114 | $sObject->setAny($this->_convertToAny($sObject->getFields())); |
||
1 ignored issue
–
show
|
|||
115 | // print_r($this->_convertToAny($sObject->getFields())); |
||
116 | } |
||
117 | } |
||
118 | $createObject = new SForce\Wsdl\create($sObjects); |
||
1 ignored issue
–
show
|
|||
119 | |||
120 | return parent::_create($createObject); |
||
121 | } |
||
122 | |||
123 | ##################################### |
||
124 | # overriding parent class to fix bugs |
||
125 | # in the parent class. |
||
126 | ##################################### |
||
127 | /** |
||
128 | * Updates one or more new individual objects to your organization's data. |
||
129 | * |
||
130 | * @param SObject[] $sObjects Array of one or more sObjects (up to 200) to update. |
||
131 | * @param null|string $type Unused |
||
132 | * |
||
133 | * @return SaveResult |
||
134 | */ |
||
135 | public function update($sObjects, $type = null) |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * NOTA BENE: |
||
149 | * added here because Describe Layout occurs two times (double) with capital D |
||
150 | * (DescribeLayout) and without capital D (changed to describeLayoutDouble) |
||
151 | * |
||
152 | * Use describeLayoutDouble to retrieve information about the layout (presentation |
||
153 | * of data to users) for a given object type. The describeLayoutDouble call returns |
||
154 | * metadata about a given page layout, including layouts for edit and |
||
155 | * display-only views and record type mappings. Note that field-level security |
||
156 | * and layout editability affects which fields appear in a layout. |
||
157 | * |
||
158 | * @param string $type Object Type |
||
159 | * @param array $recordTypeIds |
||
160 | * |
||
161 | * @return Wsdl\DescribeLayoutResult |
||
1 ignored issue
–
show
|
|||
162 | */ |
||
163 | public function describeLayoutDouble($type, array $recordTypeIds = []) |
||
172 |