1
|
|
|
<?php |
2
|
|
|
namespace Tavii\SQSJobQueueBundle\Entity; |
3
|
|
|
use Doctrine\ORM\Mapping as ORM; |
4
|
|
|
use Tavii\SQSJobQueue\Queue\QueueName; |
5
|
|
|
use Tavii\SQSJobQueue\Storage\EntityInterface; |
6
|
|
|
use Tavii\SQSJobQueue\Storage\EntityJobNameTrait; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class SqsJobQueue |
10
|
|
|
* @package Tavii\SQSJobQueueBundle\Entity |
11
|
|
|
* |
12
|
|
|
* @ORM\Entity(repositoryClass="Tavii\SQSJobQueueBundle\Repository\SqsWorkerRepository") |
13
|
|
|
* @ORM\Table(name="sqs_workers") |
14
|
|
|
* @ORM\HasLifecycleCallbacks() |
15
|
|
|
*/ |
16
|
|
|
class SqsWorker implements EntityInterface |
17
|
|
|
{ |
18
|
|
|
use EntityJobNameTrait; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @ORM\Id |
22
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
23
|
|
|
* @ORM\Column(type="bigint", name="id") |
24
|
|
|
*/ |
25
|
|
|
protected $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @ORM\Column(type="string", name="server", nullable=false) |
29
|
|
|
*/ |
30
|
|
|
protected $server; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @ORM\Column(type="string", name="queue", nullable=false) |
34
|
|
|
*/ |
35
|
|
|
protected $queue; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
* @ORM\Column(type="string", name="prefix", nullable=true) |
40
|
|
|
*/ |
41
|
|
|
protected $prefix; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @ORM\Column(type="integer", name="proc_id", nullable=false) |
45
|
|
|
*/ |
46
|
|
|
protected $procId; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @ORM\Column(type="datetime", name="created_at") |
50
|
|
|
*/ |
51
|
|
|
protected $createdAt; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @ORM\Column(type="datetime", name="updated_at") |
55
|
|
|
*/ |
56
|
|
|
protected $updatedAt; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return mixed |
60
|
|
|
*/ |
61
|
|
|
public function getId() |
62
|
|
|
{ |
63
|
|
|
return $this->id; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return mixed |
68
|
|
|
*/ |
69
|
|
|
public function getServer() |
70
|
|
|
{ |
71
|
|
|
return $this->server; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param $server |
76
|
|
|
* @return $this |
77
|
|
|
*/ |
78
|
|
|
public function setServer($server) |
79
|
|
|
{ |
80
|
|
|
$this->server = $server; |
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return mixed |
86
|
|
|
*/ |
87
|
|
|
public function getQueue() |
88
|
|
|
{ |
89
|
|
|
return $this->queue; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param $queue |
94
|
|
|
* @return $this |
95
|
|
|
*/ |
96
|
|
|
public function setQueue($queue) |
97
|
|
|
{ |
98
|
|
|
$this->queue = $queue; |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return mixed |
104
|
|
|
*/ |
105
|
|
|
public function getPrefix() |
106
|
|
|
{ |
107
|
|
|
return $this->prefix; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param mixed $prefix |
112
|
|
|
* @return $this |
113
|
|
|
*/ |
114
|
|
|
public function setPrefix($prefix) |
115
|
|
|
{ |
116
|
|
|
$this->prefix = $prefix; |
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
|
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return mixed |
124
|
|
|
*/ |
125
|
|
|
public function getProcId() |
126
|
|
|
{ |
127
|
|
|
return $this->procId; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param int $procId |
132
|
|
|
* @return $this |
133
|
|
|
*/ |
134
|
|
|
public function setProcId($procId) |
135
|
|
|
{ |
136
|
|
|
$this->procId = $procId; |
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return mixed |
142
|
|
|
*/ |
143
|
|
|
public function getStatus() |
144
|
|
|
{ |
145
|
|
|
return $this->status; |
|
|
|
|
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return mixed |
150
|
|
|
*/ |
151
|
|
|
public function getCreatedAt() |
152
|
|
|
{ |
153
|
|
|
return $this->createdAt; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param $createdAt |
158
|
|
|
* @return $this |
159
|
|
|
*/ |
160
|
|
|
public function setCreatedAt($createdAt) |
161
|
|
|
{ |
162
|
|
|
$this->createdAt = $createdAt; |
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return mixed |
168
|
|
|
*/ |
169
|
|
|
public function getUpdatedAt() |
170
|
|
|
{ |
171
|
|
|
return $this->updatedAt; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @param $updatedAt |
176
|
|
|
* @return $this |
177
|
|
|
*/ |
178
|
|
|
public function setUpdatedAt($updatedAt) |
179
|
|
|
{ |
180
|
|
|
$this->updatedAt = $updatedAt; |
181
|
|
|
return $this; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @ORM\PrePersist() |
186
|
|
|
*/ |
187
|
|
|
public function createDate() |
188
|
|
|
{ |
189
|
|
|
$this->createdAt = new \DateTime(); |
190
|
|
|
$this->updatedAt = new \DateTime(); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @ORM\PreUpdate() |
195
|
|
|
*/ |
196
|
|
|
public function updateDate() |
197
|
|
|
{ |
198
|
|
|
$this->updatedAt = new \DateTime(); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @param QueueName $queueName |
203
|
|
|
*/ |
204
|
|
|
public function setQueueName(QueueName $queueName) |
205
|
|
|
{ |
206
|
|
|
$this->prefix = $queueName->getPrefix(); |
207
|
|
|
$this->queue = $queueName->getName(); |
208
|
|
|
return $this; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
|
212
|
|
|
} |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: