1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainAltapayBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Knp\DoctrineBehaviors\Model as ORMBehaviors; |
7
|
|
|
use Symfony\Component\HttpFoundation\Request; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @ORM\MappedSuperclass |
11
|
|
|
*/ |
12
|
|
|
abstract class HttpTransaction implements HttpTransactionInterface |
13
|
|
|
{ |
14
|
|
|
use ORMBehaviors\Timestampable\Timestampable; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
* |
19
|
|
|
* @ORM\Column(type="string", nullable=true) |
20
|
|
|
*/ |
21
|
|
|
protected $ip; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
* |
26
|
|
|
* @ORM\Column(type="text") |
27
|
|
|
*/ |
28
|
|
|
protected $request; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
* |
33
|
|
|
* @ORM\Column(type="text", nullable=true) |
34
|
|
|
*/ |
35
|
|
|
protected $response; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function getIp(): string |
41
|
|
|
{ |
42
|
|
|
return $this->ip; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
|
|
public function setIp(string $ip): HttpTransactionInterface |
49
|
|
|
{ |
50
|
|
|
$this->ip = $ip; |
51
|
|
|
|
52
|
|
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
public function getRequest(): string |
59
|
|
|
{ |
60
|
|
|
return $this->request; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
|
|
public function setRequest($request): HttpTransactionInterface |
67
|
|
|
{ |
68
|
|
|
if ($request instanceof Request) { |
69
|
|
|
$this->ip = $request->getClientIp(); |
70
|
|
|
|
71
|
|
|
$post = ''; |
72
|
|
|
|
73
|
|
|
foreach ($request->request->all() as $key => $val) { |
74
|
|
|
$post .= '&'.$key.'='.$val."\r\n"; |
75
|
|
|
} |
76
|
|
|
$post = trim($post, '&'); |
77
|
|
|
|
78
|
|
|
$request = sprintf('%s %s %s', |
79
|
|
|
$request->getMethod(), |
80
|
|
|
$request->getRequestUri(), |
81
|
|
|
$request->server->get('SERVER_PROTOCOL'))."\r\n".$request->headers."\r\n".$post; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$this->request = $request; |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* {@inheritdoc} |
91
|
|
|
*/ |
92
|
|
|
public function getResponse(): string |
93
|
|
|
{ |
94
|
|
|
return $this->response; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* {@inheritdoc} |
99
|
|
|
*/ |
100
|
|
|
public function setResponse(string $response): HttpTransactionInterface |
101
|
|
|
{ |
102
|
|
|
$this->response = $response; |
103
|
|
|
|
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|