7
7
*/
8
8
9
9
use Symfony \Component \HttpFoundation \Request ;
10
- use Guzzle \Http \Message \Response ;
11
10
use Psr \Http \Message \ResponseInterface ;
12
11
use Psr \Http \Message \ServerRequestInterface ;
13
12
use SimpleXMLElement ;
@@ -20,30 +19,25 @@ class Helper
20
19
* as XML in a header line or XML in the request body.
21
20
* All of these methods are used in various places.
22
21
* XML data is parsed into a flat array.
23
- * Supports Guzzle sewrver request/response, but be
24
- * switched to PSR-7 messages in Omnipay 3.x versions.
25
22
*
26
- * @param Request|Response|TBC $httpMessage a Guzzle HTTP server request or HTTP response, or a PSR-7 message (TODO)
23
+ * @param Request|ResponseInterface $httpMessage a HTTP server request or a PSR-7 message
27
24
* @return array the data as a flat array
28
25
*/
29
26
public static function extractMessageData ($ httpMessage )
30
27
{
31
- // Guzzle 3 Response or PSR-7 response.
32
- // The assumption for now is that it will always be XML.
28
+ // The assumption for now is that a syncronous response will always be XML.
33
29
34
- if ($ httpMessage instanceof Response || $ httpMessage instanceof ResponseInterface) {
30
+ if ($ httpMessage instanceof ResponseInterface) {
35
31
$ xmlString = (string )$ httpMessage ->getBody ();
36
32
37
33
$ xmlString = simplexml_load_string ($ xmlString );
38
34
return static ::parseXmlElement ($ xmlString );
39
35
}
40
36
41
- // Guzzle 3 ServerRequest.
42
- // CHECKME: when coult this also be a ServerRequestInterface?
43
-
37
+ // Incoming server request.
44
38
// The results could be sent by GET or POST. It's an account
45
39
// option, or an overriding request option.
46
- // Could also be XML in a header or the body.
40
+ // Could also be XML in a header field or the body.
47
41
48
42
if ($ httpMessage instanceof Request) {
49
43
if (static ::getMethod ($ httpMessage ) === 'POST ' ) {
@@ -70,21 +64,16 @@ public static function extractMessageData($httpMessage)
70
64
71
65
// Fall back to standard GET query or POST form parameters.
72
66
73
- return static ::getFormData ($ httpMessage );
67
+ if (static ::getMethod ($ httpMessage ) === 'POST ' ) {
68
+ return $ httpMessage ->request ->all ();
69
+ } else {
70
+ return $ httpMessage ->query ->all ();
71
+ }
74
72
}
75
73
76
74
return [];
77
75
}
78
76
79
- public static function getFormData ($ httpMessage )
80
- {
81
- if (static ::getMethod ($ httpMessage ) === 'POST ' ) {
82
- return $ httpMessage ->request ->all ();
83
- } else {
84
- return $ httpMessage ->query ->all ();
85
- }
86
- }
87
-
88
77
public static function getMethod ($ httpMessage )
89
78
{
90
79
return strtoupper ($ httpMessage ->getMethod ());
0 commit comments