|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainAltapayBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
7
|
|
|
use Knp\DoctrineBehaviors\Model as ORMBehaviors; |
|
8
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* We use the terminology from Message Queues where an exchange is where we publish events |
|
12
|
|
|
* |
|
13
|
|
|
* @ORM\Table(name="dandomain_altapay_webhook_exchanges") |
|
14
|
|
|
* @ORM\Entity() |
|
15
|
|
|
* @UniqueEntity("url") |
|
16
|
|
|
*/ |
|
17
|
|
|
class WebhookExchange |
|
18
|
|
|
{ |
|
19
|
|
|
use ORMBehaviors\Timestampable\Timestampable; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var int |
|
23
|
|
|
* |
|
24
|
|
|
* @ORM\Id |
|
25
|
|
|
* @ORM\Column(name="id", type="integer") |
|
26
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
27
|
|
|
*/ |
|
28
|
|
|
private $id; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* This will hold the URL to where the events are published |
|
32
|
|
|
* |
|
33
|
|
|
* @var string |
|
34
|
|
|
* |
|
35
|
|
|
* @Assert\NotBlank() |
|
36
|
|
|
* @Assert\Length(max="191") |
|
37
|
|
|
* @Assert\Url() |
|
38
|
|
|
* |
|
39
|
|
|
* @ORM\Column(type="string", unique=true, length=191) |
|
40
|
|
|
*/ |
|
41
|
|
|
private $url; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* This will hold the last event id published |
|
45
|
|
|
* |
|
46
|
|
|
* @var int |
|
47
|
|
|
* |
|
48
|
|
|
* @Assert\GreaterThanOrEqual(0) |
|
49
|
|
|
* |
|
50
|
|
|
* @ORM\Column(type="integer") |
|
51
|
|
|
*/ |
|
52
|
|
|
private $lastEventId; |
|
53
|
|
|
|
|
54
|
|
|
public function __construct(string $url, int $lastEventId = 0) |
|
55
|
|
|
{ |
|
56
|
|
|
$this->url = $url; |
|
57
|
|
|
$this->lastEventId = $lastEventId; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return int |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getId(): ?int |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->id; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param int $id |
|
70
|
|
|
* @return WebhookExchange |
|
71
|
|
|
*/ |
|
72
|
|
|
public function setId(int $id) : self |
|
73
|
|
|
{ |
|
74
|
|
|
$this->id = $id; |
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getUrl(): string |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->url; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @param string $url |
|
88
|
|
|
* @return WebhookExchange |
|
89
|
|
|
*/ |
|
90
|
|
|
public function setUrl(string $url) : self |
|
91
|
|
|
{ |
|
92
|
|
|
$this->url = $url; |
|
93
|
|
|
return $this; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @return int |
|
98
|
|
|
*/ |
|
99
|
|
|
public function getLastEventId(): int |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->lastEventId; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @param int $lastEventId |
|
106
|
|
|
* @return WebhookExchange |
|
107
|
|
|
*/ |
|
108
|
|
|
public function setLastEventId(int $lastEventId) : self |
|
109
|
|
|
{ |
|
110
|
|
|
$this->lastEventId = $lastEventId; |
|
111
|
|
|
return $this; |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|