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
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @ORM\Table(name="dandomain_altapay_http_transactions") |
12
|
|
|
* @ORM\Entity() |
13
|
|
|
*/ |
14
|
|
|
class HttpTransaction |
15
|
|
|
{ |
16
|
|
|
use ORMBehaviors\Timestampable\Timestampable; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var int |
20
|
|
|
* |
21
|
|
|
* @ORM\Id |
22
|
|
|
* @ORM\Column(type="integer") |
23
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
24
|
|
|
*/ |
25
|
|
|
protected $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
* |
30
|
|
|
* @ORM\Column(type="string", nullable=true) |
31
|
|
|
*/ |
32
|
|
|
protected $ip; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
* |
37
|
|
|
* @Assert\NotBlank() |
38
|
|
|
* |
39
|
|
|
* @ORM\Column(type="text") |
40
|
|
|
*/ |
41
|
|
|
protected $request; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var string |
45
|
|
|
* |
46
|
|
|
* @Assert\NotBlank() |
47
|
|
|
* |
48
|
|
|
* @ORM\Column(type="text") |
49
|
|
|
*/ |
50
|
|
|
protected $response; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return int |
54
|
|
|
*/ |
55
|
|
|
public function getId(): int |
56
|
|
|
{ |
57
|
|
|
return $this->id; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param int $id |
62
|
|
|
* |
63
|
|
|
* @return HttpTransaction |
64
|
|
|
*/ |
65
|
|
|
public function setId(int $id): self |
66
|
|
|
{ |
67
|
|
|
$this->id = $id; |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
public function getIp(): string |
76
|
|
|
{ |
77
|
|
|
return $this->ip; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param string $ip |
82
|
|
|
* |
83
|
|
|
* @return HttpTransaction |
84
|
|
|
*/ |
85
|
|
|
public function setIp(string $ip): self |
86
|
|
|
{ |
87
|
|
|
$this->ip = $ip; |
88
|
|
|
|
89
|
|
|
return $this; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public function getRequest(): string |
96
|
|
|
{ |
97
|
|
|
return $this->request; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param $request |
102
|
|
|
* |
103
|
|
|
* @return HttpTransaction |
104
|
|
|
*/ |
105
|
|
|
public function setRequest($request): self |
106
|
|
|
{ |
107
|
|
|
if ($request instanceof Request) { |
108
|
|
|
$this->ip = $request->getClientIp(); |
109
|
|
|
|
110
|
|
|
$post = ''; |
111
|
|
|
|
112
|
|
|
foreach ($request->request->all() as $key => $val) { |
113
|
|
|
$post .= '&'.$key.'='.$val."\r\n"; |
114
|
|
|
} |
115
|
|
|
$post = trim($post, '&'); |
116
|
|
|
|
117
|
|
|
$request = sprintf('%s %s %s', |
118
|
|
|
$request->getMethod(), |
119
|
|
|
$request->getRequestUri(), |
120
|
|
|
$request->server->get('SERVER_PROTOCOL'))."\r\n".$request->headers."\r\n".$post; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
$this->request = $request; |
124
|
|
|
|
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function getResponse(): string |
132
|
|
|
{ |
133
|
|
|
return $this->response; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param string $response |
138
|
|
|
* |
139
|
|
|
* @return HttpTransaction |
140
|
|
|
*/ |
141
|
|
|
public function setResponse(string $response): self |
142
|
|
|
{ |
143
|
|
|
$this->response = $response; |
144
|
|
|
|
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
|