1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the haveibeenpwned-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\HaveIBeenPwnedBundle\Event; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\CoreBundle\Event\AbstractEvent as BaseEvent; |
15
|
|
|
use WBW\Library\HaveIBeenPwned\Entity\HaveIBeenPwnedEntityInterface; |
16
|
|
|
use WBW\Library\HaveIBeenPwned\Request\AbstractRequest; |
17
|
|
|
use WBW\Library\HaveIBeenPwned\Response\AbstractResponse; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Abstract event. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb> |
23
|
|
|
* @package WBW\Bundle\HaveIBeenPwnedBundle\Event |
24
|
|
|
* @abstract |
25
|
|
|
*/ |
26
|
|
|
abstract class AbstractEvent extends BaseEvent { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Entity. |
30
|
|
|
* |
31
|
|
|
* @var HaveIBeenPwnedEntityInterface |
32
|
|
|
*/ |
33
|
|
|
private $entity; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Request. |
37
|
|
|
* |
38
|
|
|
* @var AbstractRequest |
39
|
|
|
*/ |
40
|
|
|
private $request; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Response. |
44
|
|
|
* |
45
|
|
|
* @var AbstractResponse |
46
|
|
|
*/ |
47
|
|
|
private $response; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Constructor. |
51
|
|
|
* |
52
|
|
|
* @param string $eventName The event name. |
53
|
|
|
* @param HaveIBeenPwnedEntityInterface|null $entity The entity. |
54
|
|
|
*/ |
55
|
|
|
protected function __construct(string $eventName, HaveIBeenPwnedEntityInterface $entity = null) { |
56
|
|
|
parent::__construct($eventName); |
57
|
|
|
|
58
|
|
|
$this->setEntity($entity); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the entity. |
63
|
|
|
* |
64
|
|
|
* @return HaveIBeenPwnedEntityInterface Returns the entity. |
65
|
|
|
*/ |
66
|
|
|
protected function getEntity() { |
67
|
|
|
return $this->entity; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Get the request. |
72
|
|
|
* |
73
|
|
|
* @return AbstractRequest Returns the request. |
74
|
|
|
*/ |
75
|
|
|
protected function getRequest() { |
76
|
|
|
return $this->request; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Get the response. |
81
|
|
|
* |
82
|
|
|
* @return AbstractResponse Returns the response. |
83
|
|
|
*/ |
84
|
|
|
protected function getResponse() { |
85
|
|
|
return $this->response; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Set the entity. |
90
|
|
|
* |
91
|
|
|
* @param HaveIBeenPwnedEntityInterface|null $entity The entity. |
92
|
|
|
* @return AbstractEvent Returns this event. |
93
|
|
|
*/ |
94
|
|
|
protected function setEntity(HaveIBeenPwnedEntityInterface $entity = null) { |
95
|
|
|
$this->entity = $entity; |
96
|
|
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Set the request. |
101
|
|
|
* |
102
|
|
|
* @param AbstractRequest $request The request. |
103
|
|
|
* @return AbstractEvent Returns this event. |
104
|
|
|
*/ |
105
|
|
|
public function setRequest(AbstractRequest $request) { |
106
|
|
|
$this->request = $request; |
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Set the response. |
112
|
|
|
* |
113
|
|
|
* @param AbstractResponse $response The response. |
114
|
|
|
* @return AbstractEvent Returns this event. |
115
|
|
|
*/ |
116
|
|
|
public function setResponse(AbstractResponse $response) { |
117
|
|
|
$this->response = $response; |
118
|
|
|
return $this; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|