1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the GitControlBundle package. |
4
|
|
|
* |
5
|
|
|
* (c) Paul Schweppe <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace VersionControl\GitControlBundle\Entity; |
12
|
|
|
|
13
|
|
|
use Doctrine\ORM\Mapping as ORM; |
14
|
|
|
use VersionControl\GitControlBundle\Entity\Issues\IssueInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Issue. |
18
|
|
|
* |
19
|
|
|
* @ORM\Table(name="issue", indexes={@ORM\Index(name="fk_issue_ver_user1_idx", columns={"ver_user_id"}), @ORM\Index(name="fk_issue_project1_idx", columns={"project_id"}), @ORM\Index(name="fk_issue_issue_milestone1_idx", columns={"issue_milestone_id"})}) |
20
|
|
|
* @ORM\Entity(repositoryClass="VersionControl\GitControlBundle\Repository\IssueRepository") |
21
|
|
|
* @ORM\HasLifecycleCallbacks |
22
|
|
|
*/ |
23
|
|
|
class Issue implements IssueInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
* |
28
|
|
|
* @ORM\Column(name="title", type="string", length=255, nullable=true) |
29
|
|
|
*/ |
30
|
|
|
private $title; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
* |
35
|
|
|
* @ORM\Column(name="description", type="text", nullable=true) |
36
|
|
|
*/ |
37
|
|
|
private $description; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
* |
42
|
|
|
* @ORM\Column(name="status", type="string", length=45, nullable=true) |
43
|
|
|
*/ |
44
|
|
|
private $status; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var \DateTime |
48
|
|
|
* |
49
|
|
|
* @ORM\Column(name="closed_at", type="datetime", nullable=true) |
50
|
|
|
*/ |
51
|
|
|
private $closedAt; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var \DateTime |
55
|
|
|
* |
56
|
|
|
* @ORM\Column(name="created_at", type="datetime", nullable=true) |
57
|
|
|
*/ |
58
|
|
|
private $createdAt; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var \DateTime |
62
|
|
|
* |
63
|
|
|
* @ORM\Column(name="updated_at", type="datetime", nullable=true) |
64
|
|
|
*/ |
65
|
|
|
private $updatedAt; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var int |
69
|
|
|
* |
70
|
|
|
* @ORM\Column(name="github_number", type="integer", nullable=true) |
71
|
|
|
*/ |
72
|
|
|
private $githubNumber; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var int |
76
|
|
|
* |
77
|
|
|
* @ORM\Column(name="id", type="integer") |
78
|
|
|
* @ORM\Id |
79
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
80
|
|
|
*/ |
81
|
|
|
private $id; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @var \VersionControl\GitControlBundle\Entity\IssueMilestone |
85
|
|
|
* |
86
|
|
|
* @ORM\ManyToOne(targetEntity="VersionControl\GitControlBundle\Entity\IssueMilestone") |
87
|
|
|
* @ORM\JoinColumns({ |
88
|
|
|
* @ORM\JoinColumn(name="issue_milestone_id", referencedColumnName="id") |
89
|
|
|
* }) |
90
|
|
|
*/ |
91
|
|
|
private $issueMilestone; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @var \VersionControl\GitControlBundle\Entity\Project |
95
|
|
|
* |
96
|
|
|
* @ORM\ManyToOne(targetEntity="VersionControl\GitControlBundle\Entity\Project") |
97
|
|
|
* @ORM\JoinColumns({ |
98
|
|
|
* @ORM\JoinColumn(name="project_id", referencedColumnName="id") |
99
|
|
|
* }) |
100
|
|
|
*/ |
101
|
|
|
private $project; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @var \VersionControl\GitControlBundle\Entity\User\User |
105
|
|
|
* |
106
|
|
|
* @ORM\ManyToOne(targetEntity="VersionControl\GitControlBundle\Entity\User\User") |
107
|
|
|
* @ORM\JoinColumns({ |
108
|
|
|
* @ORM\JoinColumn(name="ver_user_id", referencedColumnName="id") |
109
|
|
|
* }) |
110
|
|
|
*/ |
111
|
|
|
private $verUser; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @var \Doctrine\Common\Collections\Collection |
115
|
|
|
* |
116
|
|
|
* @ORM\ManyToMany(targetEntity="VersionControl\GitControlBundle\Entity\IssueLabel", inversedBy="issue") |
117
|
|
|
* @ORM\JoinTable(name="issue_has_issue_label", |
118
|
|
|
* joinColumns={ |
119
|
|
|
* @ORM\JoinColumn(name="issue_id", referencedColumnName="id") |
120
|
|
|
* }, |
121
|
|
|
* inverseJoinColumns={ |
122
|
|
|
* @ORM\JoinColumn(name="issue_label_id", referencedColumnName="id") |
123
|
|
|
* } |
124
|
|
|
* ) |
125
|
|
|
*/ |
126
|
|
|
private $issueLabel; |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Issue comments. |
130
|
|
|
* |
131
|
|
|
* @var \Doctrine\Common\Collections\Collection |
132
|
|
|
* |
133
|
|
|
* @ORM\OneToMany(targetEntity="VersionControl\GitControlBundle\Entity\IssueComment", mappedBy="issue", fetch="EXTRA_LAZY") |
134
|
|
|
*/ |
135
|
|
|
private $issueComments; |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Constructor. |
139
|
|
|
*/ |
140
|
|
|
public function __construct() |
141
|
|
|
{ |
142
|
|
|
$this->issueLabel = new \Doctrine\Common\Collections\ArrayCollection(); |
143
|
|
|
$this->issueComments = new \Doctrine\Common\Collections\ArrayCollection(); |
144
|
|
|
$this->setCreatedAt(new \DateTime()); |
145
|
|
|
$this->setStatus('open'); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Set title. |
150
|
|
|
* |
151
|
|
|
* @param string $title |
152
|
|
|
* |
153
|
|
|
* @return Issue |
154
|
|
|
*/ |
155
|
|
|
public function setTitle($title) |
156
|
|
|
{ |
157
|
|
|
$this->title = $title; |
158
|
|
|
|
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Get title. |
164
|
|
|
* |
165
|
|
|
* @return string |
166
|
|
|
*/ |
167
|
|
|
public function getTitle() |
168
|
|
|
{ |
169
|
|
|
return $this->title; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Set description. |
174
|
|
|
* |
175
|
|
|
* @param string $description |
176
|
|
|
* |
177
|
|
|
* @return Issue |
178
|
|
|
*/ |
179
|
|
|
public function setDescription($description) |
180
|
|
|
{ |
181
|
|
|
$this->description = $description; |
182
|
|
|
|
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Get description. |
188
|
|
|
* |
189
|
|
|
* @return string |
190
|
|
|
*/ |
191
|
|
|
public function getDescription() |
192
|
|
|
{ |
193
|
|
|
return $this->description; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Set status. |
198
|
|
|
* |
199
|
|
|
* @param string $status |
200
|
|
|
* |
201
|
|
|
* @return Issue |
202
|
|
|
*/ |
203
|
|
|
public function setStatus($status) |
204
|
|
|
{ |
205
|
|
|
$this->status = $status; |
206
|
|
|
|
207
|
|
|
return $this; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* Get status. |
212
|
|
|
* |
213
|
|
|
* @return string |
214
|
|
|
*/ |
215
|
|
|
public function getStatus() |
216
|
|
|
{ |
217
|
|
|
return $this->status; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Set closedAt. |
222
|
|
|
* |
223
|
|
|
* @param \DateTime $closedAt |
224
|
|
|
* |
225
|
|
|
* @return Issue |
226
|
|
|
*/ |
227
|
|
|
public function setClosedAt($closedAt) |
228
|
|
|
{ |
229
|
|
|
$this->closedAt = $closedAt; |
230
|
|
|
|
231
|
|
|
return $this; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Get closedAt. |
236
|
|
|
* |
237
|
|
|
* @return \DateTime |
238
|
|
|
*/ |
239
|
|
|
public function getClosedAt() |
240
|
|
|
{ |
241
|
|
|
return $this->closedAt; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* Set createdAt. |
246
|
|
|
* |
247
|
|
|
* @param \DateTime $createdAt |
248
|
|
|
* |
249
|
|
|
* @return Issue |
250
|
|
|
*/ |
251
|
|
|
public function setCreatedAt($createdAt) |
252
|
|
|
{ |
253
|
|
|
$this->createdAt = $createdAt; |
254
|
|
|
|
255
|
|
|
return $this; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Get createdAt. |
260
|
|
|
* |
261
|
|
|
* @return \DateTime |
262
|
|
|
*/ |
263
|
|
|
public function getCreatedAt() |
264
|
|
|
{ |
265
|
|
|
return $this->createdAt; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* Set updatedAt. |
270
|
|
|
* |
271
|
|
|
* @param \DateTime $updatedAt |
272
|
|
|
* |
273
|
|
|
* @return Issue |
274
|
|
|
*/ |
275
|
|
|
public function setUpdatedAt($updatedAt) |
276
|
|
|
{ |
277
|
|
|
$this->updatedAt = $updatedAt; |
278
|
|
|
|
279
|
|
|
return $this; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* Get updatedAt. |
284
|
|
|
* |
285
|
|
|
* @return \DateTime |
286
|
|
|
*/ |
287
|
|
|
public function getUpdatedAt() |
288
|
|
|
{ |
289
|
|
|
return $this->updatedAt; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* Set githubNumber. |
294
|
|
|
* |
295
|
|
|
* @param int $githubNumber |
296
|
|
|
* |
297
|
|
|
* @return Issue |
298
|
|
|
*/ |
299
|
|
|
public function setGithubNumber($githubNumber) |
300
|
|
|
{ |
301
|
|
|
$this->githubNumber = $githubNumber; |
302
|
|
|
|
303
|
|
|
return $this; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* Get githubNumber. |
308
|
|
|
* |
309
|
|
|
* @return int |
310
|
|
|
*/ |
311
|
|
|
public function getGithubNumber() |
312
|
|
|
{ |
313
|
|
|
return $this->githubNumber; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* Get id. |
318
|
|
|
* |
319
|
|
|
* @return int |
320
|
|
|
*/ |
321
|
|
|
public function getId() |
322
|
|
|
{ |
323
|
|
|
return $this->id; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* Set issueMilestone. |
328
|
|
|
* |
329
|
|
|
* @param \VersionControl\GitControlBundle\Entity\IssueMilestone $issueMilestone |
330
|
|
|
* |
331
|
|
|
* @return Issue |
332
|
|
|
*/ |
333
|
|
|
public function setIssueMilestone(\VersionControl\GitControlBundle\Entity\IssueMilestone $issueMilestone = null) |
334
|
|
|
{ |
335
|
|
|
$this->issueMilestone = $issueMilestone; |
336
|
|
|
|
337
|
|
|
return $this; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* Get issueMilestone. |
342
|
|
|
* |
343
|
|
|
* @return \VersionControl\GitControlBundle\Entity\IssueMilestone |
344
|
|
|
*/ |
345
|
|
|
public function getIssueMilestone() |
346
|
|
|
{ |
347
|
|
|
return $this->issueMilestone; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Set project. |
352
|
|
|
* |
353
|
|
|
* @param \VersionControl\GitControlBundle\Entity\Project $project |
354
|
|
|
* |
355
|
|
|
* @return Issue |
356
|
|
|
*/ |
357
|
|
|
public function setProject(\VersionControl\GitControlBundle\Entity\Project $project = null) |
358
|
|
|
{ |
359
|
|
|
$this->project = $project; |
360
|
|
|
|
361
|
|
|
return $this; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* Get project. |
366
|
|
|
* |
367
|
|
|
* @return \VersionControl\GitControlBundle\Entity\Project |
368
|
|
|
*/ |
369
|
|
|
public function getProject() |
370
|
|
|
{ |
371
|
|
|
return $this->project; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* Set verUser. |
376
|
|
|
* |
377
|
|
|
* @param \VersionControl\GitControlBundle\Entity\User\User $verUser |
378
|
|
|
* |
379
|
|
|
* @return Issue |
380
|
|
|
*/ |
381
|
|
|
public function setVerUser(\VersionControl\GitControlBundle\Entity\User\User $verUser = null) |
382
|
|
|
{ |
383
|
|
|
$this->verUser = $verUser; |
384
|
|
|
|
385
|
|
|
return $this; |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
/** |
389
|
|
|
* Get User. |
390
|
|
|
* |
391
|
|
|
* @return \VersionControl\GitControlBundle\Entity\Issues\IssueUserInterface |
392
|
|
|
*/ |
393
|
|
|
public function getUser() |
394
|
|
|
{ |
395
|
|
|
return $this->verUser; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* Get verUser. |
400
|
|
|
* |
401
|
|
|
* @return \VersionControl\GitControlBundle\Entity\User\User |
402
|
|
|
*/ |
403
|
|
|
public function getVerUser() |
404
|
|
|
{ |
405
|
|
|
return $this->verUser; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
/** |
409
|
|
|
* Add issueLabel. |
410
|
|
|
* |
411
|
|
|
* @param \VersionControl\GitControlBundle\Entity\IssueLabel $issueLabel |
412
|
|
|
* |
413
|
|
|
* @return Issue |
414
|
|
|
*/ |
415
|
|
|
public function addIssueLabel(\VersionControl\GitControlBundle\Entity\Issues\IssueLabel $issueLabel) |
416
|
|
|
{ |
417
|
|
|
$this->issueLabel[] = $issueLabel; |
418
|
|
|
|
419
|
|
|
return $this; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* Remove issueLabel. |
424
|
|
|
* |
425
|
|
|
* @param \VersionControl\GitControlBundle\Entity\IssueLabel $issueLabel |
426
|
|
|
*/ |
427
|
|
|
public function removeIssueLabel(\VersionControl\GitControlBundle\Entity\Issues\IssueLabel $issueLabel) |
428
|
|
|
{ |
429
|
|
|
$this->issueLabel->removeElement($issueLabel); |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
/** |
433
|
|
|
* Get issueLabel. |
434
|
|
|
* |
435
|
|
|
* @return \Doctrine\Common\Collections\Collection |
436
|
|
|
*/ |
437
|
|
|
public function getIssueLabel() |
438
|
|
|
{ |
439
|
|
|
return $this->issueLabel; |
|
|
|
|
440
|
|
|
} |
441
|
|
|
|
442
|
|
|
/** |
443
|
|
|
* Get Issue Comments. |
444
|
|
|
* |
445
|
|
|
* @return \Doctrine\Common\Collections\Collection of \VersionControl\GitControlBundle\Entity\IssueComment |
446
|
|
|
*/ |
447
|
|
|
public function getIssueComments() |
448
|
|
|
{ |
449
|
|
|
return $this->issueComments; |
|
|
|
|
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* Set Issue Comments. |
454
|
|
|
* |
455
|
|
|
* @param \Doctrine\Common\Collections\Collection $issueComments |
456
|
|
|
* |
457
|
|
|
* @return \VersionControl\GitControlBundle\Entity\Issue |
458
|
|
|
*/ |
459
|
|
|
public function setIssueComments(array $issueComments) |
460
|
|
|
{ |
461
|
|
|
$this->issueComments = $issueComments; |
|
|
|
|
462
|
|
|
|
463
|
|
|
return $this; |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
/** |
467
|
|
|
* @ORM\PrePersist() |
468
|
|
|
* @ORM\PreUpdate() |
469
|
|
|
*/ |
470
|
|
|
public function updateModifiedDatetime() |
471
|
|
|
{ |
472
|
|
|
// update the modified time |
473
|
|
|
//$this->setCreatedAt(new \DateTime()); |
474
|
|
|
$this->setUpdatedAt(new \DateTime()); |
475
|
|
|
if ($this->getStatus() === 'closed') { |
476
|
|
|
$this->setClosedAt(new \DateTime()); |
477
|
|
|
} |
478
|
|
|
} |
479
|
|
|
|
480
|
|
|
/** |
481
|
|
|
* Set status. |
482
|
|
|
* |
483
|
|
|
* @param string $status |
484
|
|
|
* |
485
|
|
|
* @return Issue |
486
|
|
|
*/ |
487
|
|
|
public function setClosed() |
488
|
|
|
{ |
489
|
|
|
$this->status = 'closed'; |
490
|
|
|
|
491
|
|
|
return $this; |
|
|
|
|
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
/** |
495
|
|
|
* Set status. |
496
|
|
|
* |
497
|
|
|
* @param string $status |
498
|
|
|
* |
499
|
|
|
* @return Issue |
500
|
|
|
*/ |
501
|
|
|
public function setOpen() |
502
|
|
|
{ |
503
|
|
|
$this->status = 'open'; |
504
|
|
|
|
505
|
|
|
return $this; |
|
|
|
|
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
public function isClosed() |
509
|
|
|
{ |
510
|
|
|
return ($this->status === 'closed') ? true : false; |
511
|
|
|
} |
512
|
|
|
} |
513
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: