1 | <?php |
||
35 | abstract class StandardResponseHandler implements MessageResponseHandler |
||
36 | { |
||
37 | /** |
||
38 | * Default namespace prefix we'll be using for xpath queries |
||
39 | * |
||
40 | * Why not "m"? It's as good as any other letter. |
||
41 | */ |
||
42 | const XMLNS_PREFIX = "m"; |
||
43 | |||
44 | /** |
||
45 | * Analyze response by looking for error, category and message with the provided XPATH queries |
||
46 | * |
||
47 | * xpath queries must be prefixed with the namespace self::XMLNS_PREFIX |
||
48 | * |
||
49 | * @param SendResult $response |
||
50 | * @param string $qErr XPATH query for fetching error code (first node is used) |
||
51 | * @param string $qCat XPATH query for fetching error category (first node is used) |
||
52 | * @param string $qMsg XPATH query for fetching error messages (all nodes are used) |
||
53 | * @param string|null $errLevel Optional custom error level string. |
||
54 | * @return Result |
||
55 | */ |
||
56 | 11 | protected function analyzeWithErrCodeCategoryMsgQuery(SendResult $response, $qErr, $qCat, $qMsg, $errLevel = null) |
|
83 | |||
84 | /** |
||
85 | * Analyze response by looking for error, message and level with the provided XPATH queries |
||
86 | * |
||
87 | * Result status defaults to Result::STATUS_ERROR if any error is found. |
||
88 | * |
||
89 | * xpath queries must be prefixed with the namespace self::XMLNS_PREFIX |
||
90 | * |
||
91 | * @param SendResult $response |
||
92 | * @param string $qErr XPATH query for fetching error code (first node is used) |
||
93 | * @param string $qMsg XPATH query for fetching error messages (all nodes are used) |
||
94 | * @param string $qLvl XPATH query for fetching error level (first node is used) |
||
95 | * @param array $lvlToText Level-to-text translation |
||
96 | * @return Result |
||
97 | */ |
||
98 | 1 | protected function analyzeWithErrorCodeMsgQueryLevel(SendResult $response, $qErr, $qMsg, $qLvl, $lvlToText) |
|
129 | |||
130 | /** |
||
131 | * Analyse with XPATH queries for error code and message, provide fixed category |
||
132 | * |
||
133 | * @param SendResult $response |
||
134 | * @param string $qErr XPATH query for fetching error code (first node is used) |
||
135 | * @param string $qMsg XPATH query for fetching error messages (all nodes are used) |
||
136 | * @param string $category Result::STATUS_* The fixed error category (status) |
||
137 | * @return Result |
||
138 | */ |
||
139 | 1 | public function analyzeWithErrCodeAndMsgQueryFixedCat(SendResult $response, $qErr, $qMsg, $category) |
|
161 | |||
162 | /** |
||
163 | * Analyze response by looking for error, category and message in nodes specified by name |
||
164 | * |
||
165 | * @param SendResult $response |
||
166 | * @param string $nodeErr Node name of the node containing the error code (first node is used) |
||
167 | * @param string $nodeCat Node name of the node containing the error category (first node is used) |
||
168 | * @param string $nodeMsg Node name of the node containing the error messages (all nodes are used) |
||
169 | * @return Result |
||
170 | */ |
||
171 | 39 | protected function analyzeWithErrCodeCategoryMsgNodeName(SendResult $response, $nodeErr, $nodeCat, $nodeMsg) |
|
198 | |||
199 | |||
200 | /** |
||
201 | * @param SendResult $response WebService message Send Result |
||
202 | * @return Result |
||
203 | * @throws Exception |
||
204 | */ |
||
205 | 30 | protected function analyzeSimpleResponseErrorCodeAndMessage($response) |
|
214 | |||
215 | /** |
||
216 | * @param SendResult $response WebService message Send Result |
||
217 | * @return Result |
||
218 | * @throws Exception |
||
219 | */ |
||
220 | 5 | protected function analyzeSimpleResponseErrorCodeAndMessageStatusCode($response) |
|
229 | |||
230 | /** |
||
231 | * Make a Xpath-queryable object for an XML string |
||
232 | * |
||
233 | * registers TNS namespace with prefix self::XMLNS_PREFIX |
||
234 | * |
||
235 | * @param string $response |
||
236 | * @return \DOMXPath |
||
237 | * @throws Exception when there's a problem loading the message |
||
238 | */ |
||
239 | 52 | protected function makeDomXpath($response) |
|
251 | |||
252 | /** |
||
253 | * @param string $response |
||
254 | * @return \DOMDocument |
||
255 | * @throws Exception when there's a problem loading the message |
||
256 | */ |
||
257 | 95 | protected function loadDomDocument($response) |
|
268 | |||
269 | /** |
||
270 | * Converts a status code found in an error message to the appropriate status level |
||
271 | * |
||
272 | * if no node found (= $qualifier is a null), $defaultStatus will be used |
||
273 | * |
||
274 | * @param string|null $qualifier |
||
275 | * @param string $defaultStatus the default status to fall back to if no qualifier is present |
||
276 | * @return string Result::STATUS_* |
||
277 | */ |
||
278 | 43 | protected function makeStatusFromErrorQualifier($qualifier, $defaultStatus = Result::STATUS_ERROR) |
|
305 | |||
306 | /** |
||
307 | * Convert a DomNodeList of nodes containing a (potentially partial) error message into a string. |
||
308 | * |
||
309 | * @param \DOMNodeList $errorTextNodeList |
||
310 | * @return string|null |
||
311 | */ |
||
312 | 50 | protected function makeMessageFromMessagesNodeList($errorTextNodeList) |
|
324 | } |
||
325 |