1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\CaseBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\Common\Collections\Collection; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
|
9
|
|
|
use Oro\Bundle\EmailBundle\Model\EmailHolderInterface; |
10
|
|
|
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config; |
11
|
|
|
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField; |
12
|
|
|
use Oro\Bundle\DataAuditBundle\Metadata\Annotation as Oro; |
13
|
|
|
|
14
|
|
|
use Oro\Bundle\OrganizationBundle\Entity\Organization; |
15
|
|
|
use Oro\Bundle\UserBundle\Entity\User; |
16
|
|
|
use OroCRM\Bundle\CaseBundle\Model\ExtendCaseEntity; |
17
|
|
|
use OroCRM\Bundle\ContactBundle\Entity\Contact; |
18
|
|
|
use OroCRM\Bundle\AccountBundle\Entity\Account; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @ORM\Entity |
22
|
|
|
* @ORM\Table( |
23
|
|
|
* name="orocrm_case" |
24
|
|
|
* ) |
25
|
|
|
* @ORM\HasLifecycleCallbacks() |
26
|
|
|
* @Oro\Loggable |
27
|
|
|
* @Config( |
28
|
|
|
* routeName="orocrm_case_index", |
29
|
|
|
* routeView="orocrm_case_view", |
30
|
|
|
* defaultValues={ |
31
|
|
|
* "dataaudit"={ |
32
|
|
|
* "auditable"=true |
33
|
|
|
* }, |
34
|
|
|
* "entity"={ |
35
|
|
|
* "icon"="icon-list-alt", |
36
|
|
|
* "context-grid"="cases-for-context-grid" |
37
|
|
|
* }, |
38
|
|
|
* "ownership"={ |
39
|
|
|
* "owner_type"="USER", |
40
|
|
|
* "owner_field_name"="owner", |
41
|
|
|
* "owner_column_name"="owner_id", |
42
|
|
|
* "organization_field_name"="organization", |
43
|
|
|
* "organization_column_name"="organization_id" |
44
|
|
|
* }, |
45
|
|
|
* "security"={ |
46
|
|
|
* "type"="ACL" |
47
|
|
|
* }, |
48
|
|
|
* "tag"={ |
49
|
|
|
* "enabled"=true, |
50
|
|
|
* "immutable"=true |
51
|
|
|
* } |
52
|
|
|
* } |
53
|
|
|
* ) |
54
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) |
55
|
|
|
*/ |
56
|
|
|
class CaseEntity extends ExtendCaseEntity implements EmailHolderInterface |
57
|
|
|
{ |
58
|
|
|
/** |
59
|
|
|
* @var integer |
60
|
|
|
* |
61
|
|
|
* @ORM\Column(type="integer") |
62
|
|
|
* @ORM\Id |
63
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
64
|
|
|
* @ConfigField( |
65
|
|
|
* defaultValues={ |
66
|
|
|
* "dataaudit"={ |
67
|
|
|
* "auditable"=true |
68
|
|
|
* } |
69
|
|
|
* } |
70
|
|
|
* ) |
71
|
|
|
*/ |
72
|
|
|
protected $id; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var string |
76
|
|
|
* |
77
|
|
|
* @ORM\Column(name="subject", type="string", length=255) |
78
|
|
|
* @Oro\Versioned |
79
|
|
|
* @ConfigField( |
80
|
|
|
* defaultValues={ |
81
|
|
|
* "dataaudit"={ |
82
|
|
|
* "auditable"=true |
83
|
|
|
* } |
84
|
|
|
* } |
85
|
|
|
* ) |
86
|
|
|
*/ |
87
|
|
|
protected $subject; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @var string |
91
|
|
|
* |
92
|
|
|
* @ORM\Column(name="description", type="text", nullable=true) |
93
|
|
|
* @Oro\Versioned |
94
|
|
|
* @ConfigField( |
95
|
|
|
* defaultValues={ |
96
|
|
|
* "dataaudit"={ |
97
|
|
|
* "auditable"=true |
98
|
|
|
* } |
99
|
|
|
* } |
100
|
|
|
* ) |
101
|
|
|
*/ |
102
|
|
|
protected $description; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @var string |
106
|
|
|
* |
107
|
|
|
* @ORM\Column(name="resolution", type="text", nullable=true) |
108
|
|
|
* @Oro\Versioned |
109
|
|
|
* @ConfigField( |
110
|
|
|
* defaultValues={ |
111
|
|
|
* "dataaudit"={ |
112
|
|
|
* "auditable"=true |
113
|
|
|
* } |
114
|
|
|
* } |
115
|
|
|
* ) |
116
|
|
|
*/ |
117
|
|
|
protected $resolution; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @var CaseSource |
121
|
|
|
* |
122
|
|
|
* @ORM\ManyToOne(targetEntity="CaseSource") |
123
|
|
|
* @ORM\JoinColumn(name="source_name", referencedColumnName="name", onDelete="SET NULL") |
124
|
|
|
* @Oro\Versioned |
125
|
|
|
* @ConfigField( |
126
|
|
|
* defaultValues={ |
127
|
|
|
* "dataaudit"={ |
128
|
|
|
* "auditable"=true |
129
|
|
|
* } |
130
|
|
|
* } |
131
|
|
|
* ) |
132
|
|
|
*/ |
133
|
|
|
protected $source; |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @var CaseStatus |
137
|
|
|
* |
138
|
|
|
* @ORM\ManyToOne(targetEntity="CaseStatus") |
139
|
|
|
* @ORM\JoinColumn(name="status_name", referencedColumnName="name", onDelete="SET NULL") |
140
|
|
|
* @Oro\Versioned |
141
|
|
|
* @ConfigField( |
142
|
|
|
* defaultValues={ |
143
|
|
|
* "dataaudit"={ |
144
|
|
|
* "auditable"=true |
145
|
|
|
* } |
146
|
|
|
* } |
147
|
|
|
* ) |
148
|
|
|
*/ |
149
|
|
|
protected $status; |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @var CasePriority |
153
|
|
|
* |
154
|
|
|
* @ORM\ManyToOne(targetEntity="CasePriority") |
155
|
|
|
* @ORM\JoinColumn(name="priority_name", referencedColumnName="name", onDelete="SET NULL") |
156
|
|
|
* @Oro\Versioned |
157
|
|
|
* @ConfigField( |
158
|
|
|
* defaultValues={ |
159
|
|
|
* "dataaudit"={ |
160
|
|
|
* "auditable"=true |
161
|
|
|
* } |
162
|
|
|
* } |
163
|
|
|
* ) |
164
|
|
|
*/ |
165
|
|
|
protected $priority; |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @var Contact |
169
|
|
|
* |
170
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\ContactBundle\Entity\Contact") |
171
|
|
|
* @ORM\JoinColumn(name="related_contact_id", referencedColumnName="id", onDelete="SET NULL") |
172
|
|
|
* @ConfigField( |
173
|
|
|
* defaultValues={ |
174
|
|
|
* "dataaudit"={ |
175
|
|
|
* "auditable"=true |
176
|
|
|
* } |
177
|
|
|
* } |
178
|
|
|
* ) |
179
|
|
|
*/ |
180
|
|
|
protected $relatedContact; |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @var Account |
184
|
|
|
* |
185
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\AccountBundle\Entity\Account") |
186
|
|
|
* @ORM\JoinColumn(name="related_account_id", referencedColumnName="id", onDelete="SET NULL") |
187
|
|
|
* @ConfigField( |
188
|
|
|
* defaultValues={ |
189
|
|
|
* "dataaudit"={ |
190
|
|
|
* "auditable"=true |
191
|
|
|
* } |
192
|
|
|
* } |
193
|
|
|
* ) |
194
|
|
|
*/ |
195
|
|
|
protected $relatedAccount; |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* @var User |
199
|
|
|
* |
200
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
201
|
|
|
* @ORM\JoinColumn(name="assigned_to_id", referencedColumnName="id", onDelete="SET NULL") |
202
|
|
|
* @ConfigField( |
203
|
|
|
* defaultValues={ |
204
|
|
|
* "dataaudit"={ |
205
|
|
|
* "auditable"=true |
206
|
|
|
* } |
207
|
|
|
* } |
208
|
|
|
* ) |
209
|
|
|
* @Oro\Versioned |
210
|
|
|
*/ |
211
|
|
|
protected $assignedTo; |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @var User |
215
|
|
|
* |
216
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
217
|
|
|
* @ORM\JoinColumn(name="owner_id", referencedColumnName="id", onDelete="SET NULL") |
218
|
|
|
* @Oro\Versioned |
219
|
|
|
* @ConfigField( |
220
|
|
|
* defaultValues={ |
221
|
|
|
* "dataaudit"={ |
222
|
|
|
* "auditable"=true |
223
|
|
|
* } |
224
|
|
|
* } |
225
|
|
|
* ) |
226
|
|
|
*/ |
227
|
|
|
protected $owner; |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* @var Collection |
231
|
|
|
* |
232
|
|
|
* @ORM\OneToMany( |
233
|
|
|
* targetEntity="CaseComment", |
234
|
|
|
* mappedBy="case", |
235
|
|
|
* cascade={"ALL"}, |
236
|
|
|
* orphanRemoval=true |
237
|
|
|
* ) |
238
|
|
|
* @ORM\OrderBy({"createdAt"="DESC"}) |
239
|
|
|
*/ |
240
|
|
|
protected $comments; |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @var \DateTime |
244
|
|
|
* |
245
|
|
|
* @ORM\Column(type="datetime") |
246
|
|
|
* @ConfigField( |
247
|
|
|
* defaultValues={ |
248
|
|
|
* "entity"={ |
249
|
|
|
* "label"="oro.ui.created_at" |
250
|
|
|
* } |
251
|
|
|
* } |
252
|
|
|
* ) |
253
|
|
|
*/ |
254
|
|
|
protected $createdAt; |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @var \DateTime |
258
|
|
|
* |
259
|
|
|
* @ORM\Column(type="datetime", nullable=true) |
260
|
|
|
* @ConfigField( |
261
|
|
|
* defaultValues={ |
262
|
|
|
* "entity"={ |
263
|
|
|
* "label"="oro.ui.updated_at" |
264
|
|
|
* } |
265
|
|
|
* } |
266
|
|
|
* ) |
267
|
|
|
*/ |
268
|
|
|
protected $updatedAt; |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @var \DateTime |
272
|
|
|
* |
273
|
|
|
* @ORM\Column(type="datetime") |
274
|
|
|
*/ |
275
|
|
|
protected $reportedAt; |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* @var \DateTime |
279
|
|
|
* |
280
|
|
|
* @ORM\Column(type="datetime", nullable=true) |
281
|
|
|
*/ |
282
|
|
|
protected $closedAt; |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Flag to update closedAt field when status is set to closed. |
286
|
|
|
* Use null instead of false because of behaviour of BeSimpleSoapBundle. |
287
|
|
|
* |
288
|
|
|
* @var bool |
289
|
|
|
*/ |
290
|
|
|
private $updateClosedAt = null; |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @var Organization |
294
|
|
|
* |
295
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization") |
296
|
|
|
* @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL") |
297
|
|
|
*/ |
298
|
|
|
protected $organization; |
299
|
|
|
|
300
|
|
|
public function __construct() |
301
|
|
|
{ |
302
|
|
|
parent::__construct(); |
303
|
|
|
|
304
|
|
|
$this->comments = new ArrayCollection(); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @return integer |
309
|
|
|
*/ |
310
|
|
|
public function getId() |
311
|
|
|
{ |
312
|
|
|
return $this->id; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @param string $subject |
317
|
|
|
* @return CaseEntity |
318
|
|
|
*/ |
319
|
|
|
public function setSubject($subject) |
320
|
|
|
{ |
321
|
|
|
$this->subject = $subject; |
322
|
|
|
|
323
|
|
|
return $this; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* @return string |
328
|
|
|
*/ |
329
|
|
|
public function getSubject() |
330
|
|
|
{ |
331
|
|
|
return $this->subject; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @param string $description |
336
|
|
|
* @return CaseEntity |
337
|
|
|
*/ |
338
|
|
|
public function setDescription($description) |
339
|
|
|
{ |
340
|
|
|
$this->description = $description; |
341
|
|
|
|
342
|
|
|
return $this; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* @return string |
347
|
|
|
*/ |
348
|
|
|
public function getDescription() |
349
|
|
|
{ |
350
|
|
|
return $this->description; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* @param string $resolution |
355
|
|
|
* @return CaseEntity |
356
|
|
|
*/ |
357
|
|
|
public function setResolution($resolution) |
358
|
|
|
{ |
359
|
|
|
$this->resolution = $resolution; |
360
|
|
|
|
361
|
|
|
return $this; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* @return string |
366
|
|
|
*/ |
367
|
|
|
public function getResolution() |
368
|
|
|
{ |
369
|
|
|
return $this->resolution; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* @param CaseSource|null $source |
374
|
|
|
* @return CaseEntity |
375
|
|
|
*/ |
376
|
|
|
public function setSource($source) |
377
|
|
|
{ |
378
|
|
|
$this->source = $source; |
379
|
|
|
|
380
|
|
|
return $this; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* @return CaseSource |
385
|
|
|
*/ |
386
|
|
|
public function getSource() |
387
|
|
|
{ |
388
|
|
|
return $this->source; |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* @param CaseStatus|null $status |
393
|
|
|
* @return CaseEntity |
394
|
|
|
*/ |
395
|
|
|
public function setStatus($status) |
396
|
|
|
{ |
397
|
|
|
$this->updateClosedAt($status, $this->status); |
398
|
|
|
$this->status = $status; |
399
|
|
|
|
400
|
|
|
return $this; |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
/** |
404
|
|
|
* @param mixed $newStatus |
405
|
|
|
* @param mixed $oldStatus |
406
|
|
|
*/ |
407
|
|
|
protected function updateClosedAt($newStatus, $oldStatus) |
408
|
|
|
{ |
409
|
|
|
if ($newStatus instanceof CaseStatus && |
410
|
|
|
$newStatus->getName() == CaseStatus::STATUS_CLOSED && |
411
|
|
|
!$newStatus->isEqualTo($oldStatus) |
412
|
|
|
) { |
413
|
|
|
$this->updateClosedAt = true; |
414
|
|
|
} else { |
415
|
|
|
$this->updateClosedAt = null; |
416
|
|
|
} |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* @return CaseStatus |
421
|
|
|
*/ |
422
|
|
|
public function getStatus() |
423
|
|
|
{ |
424
|
|
|
return $this->status; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* @param CasePriority|null $priority |
429
|
|
|
* @return CaseEntity |
430
|
|
|
*/ |
431
|
|
|
public function setPriority($priority) |
432
|
|
|
{ |
433
|
|
|
$this->priority = $priority; |
434
|
|
|
|
435
|
|
|
return $this; |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* @return CasePriority |
440
|
|
|
*/ |
441
|
|
|
public function getPriority() |
442
|
|
|
{ |
443
|
|
|
return $this->priority; |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* @param Contact|null $relatedContact |
448
|
|
|
* @return CaseEntity |
449
|
|
|
*/ |
450
|
|
|
public function setRelatedContact($relatedContact = null) |
451
|
|
|
{ |
452
|
|
|
$this->relatedContact = $relatedContact; |
453
|
|
|
|
454
|
|
|
return $this; |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
/** |
458
|
|
|
* @return Contact |
459
|
|
|
*/ |
460
|
|
|
public function getRelatedContact() |
461
|
|
|
{ |
462
|
|
|
return $this->relatedContact; |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
/** |
466
|
|
|
* @param Account|null $relatedAccount |
467
|
|
|
* @return CaseEntity |
468
|
|
|
*/ |
469
|
|
|
public function setRelatedAccount($relatedAccount = null) |
470
|
|
|
{ |
471
|
|
|
$this->relatedAccount = $relatedAccount; |
472
|
|
|
|
473
|
|
|
return $this; |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* @return Account |
478
|
|
|
*/ |
479
|
|
|
public function getRelatedAccount() |
480
|
|
|
{ |
481
|
|
|
return $this->relatedAccount; |
482
|
|
|
} |
483
|
|
|
|
484
|
|
|
/** |
485
|
|
|
* @param User $assignee |
486
|
|
|
* @return CaseEntity |
487
|
|
|
*/ |
488
|
|
|
public function setAssignedTo($assignee) |
489
|
|
|
{ |
490
|
|
|
$this->assignedTo = $assignee; |
491
|
|
|
|
492
|
|
|
return $this; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
/** |
496
|
|
|
* @return User|null |
497
|
|
|
*/ |
498
|
|
|
public function getAssignedTo() |
499
|
|
|
{ |
500
|
|
|
return $this->assignedTo; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/** |
504
|
|
|
* @param User $owner |
505
|
|
|
* @return CaseEntity |
506
|
|
|
*/ |
507
|
|
|
public function setOwner($owner) |
508
|
|
|
{ |
509
|
|
|
$this->owner = $owner; |
510
|
|
|
|
511
|
|
|
return $this; |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
/** |
515
|
|
|
* @return User |
516
|
|
|
*/ |
517
|
|
|
public function getOwner() |
518
|
|
|
{ |
519
|
|
|
return $this->owner; |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* @return Collection |
524
|
|
|
*/ |
525
|
|
|
public function getComments() |
526
|
|
|
{ |
527
|
|
|
return $this->comments; |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* @param CaseComment $comment |
532
|
|
|
* @return CaseEntity |
533
|
|
|
*/ |
534
|
|
|
public function addComment(CaseComment $comment) |
535
|
|
|
{ |
536
|
|
|
$this->comments->add($comment); |
537
|
|
|
$comment->setCase($this); |
538
|
|
|
|
539
|
|
|
return $this; |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
/** |
543
|
|
|
* @param \DateTime $createdAt |
544
|
|
|
* @return CaseEntity |
545
|
|
|
*/ |
546
|
|
|
public function setCreatedAt(\DateTime $createdAt) |
547
|
|
|
{ |
548
|
|
|
$this->createdAt = $createdAt; |
549
|
|
|
|
550
|
|
|
return $this; |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
/** |
554
|
|
|
* @return \DateTime |
555
|
|
|
*/ |
556
|
|
|
public function getCreatedAt() |
557
|
|
|
{ |
558
|
|
|
return $this->createdAt; |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
/** |
562
|
|
|
* @param \DateTime $updatedAt |
563
|
|
|
* @return CaseEntity |
564
|
|
|
*/ |
565
|
|
|
public function setUpdatedAt(\DateTime $updatedAt) |
566
|
|
|
{ |
567
|
|
|
$this->updatedAt = $updatedAt; |
568
|
|
|
|
569
|
|
|
return $this; |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
/** |
573
|
|
|
* @return \DateTime |
574
|
|
|
*/ |
575
|
|
|
public function getUpdatedAt() |
576
|
|
|
{ |
577
|
|
|
return $this->updatedAt; |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
/** |
581
|
|
|
* @param \DateTime $reportedAt |
582
|
|
|
* @return CaseEntity |
583
|
|
|
*/ |
584
|
|
|
public function setReportedAt(\DateTime $reportedAt = null) |
585
|
|
|
{ |
586
|
|
|
$this->reportedAt = $reportedAt; |
587
|
|
|
|
588
|
|
|
return $this; |
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
/** |
592
|
|
|
* @return \DateTime |
593
|
|
|
*/ |
594
|
|
|
public function getReportedAt() |
595
|
|
|
{ |
596
|
|
|
return $this->reportedAt; |
597
|
|
|
} |
598
|
|
|
|
599
|
|
|
/** |
600
|
|
|
* @param \DateTime $closedAt |
601
|
|
|
* @return CaseEntity |
602
|
|
|
*/ |
603
|
|
|
public function setClosedAt(\DateTime $closedAt = null) |
604
|
|
|
{ |
605
|
|
|
$this->closedAt = $closedAt; |
606
|
|
|
|
607
|
|
|
if ($this->closedAt) { |
608
|
|
|
unset($this->updateClosedAt); |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
return $this; |
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
/** |
615
|
|
|
* @return \DateTime |
616
|
|
|
*/ |
617
|
|
|
public function getClosedAt() |
618
|
|
|
{ |
619
|
|
|
return $this->closedAt; |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
/** |
623
|
|
|
* Get the primary email address of the related contact |
624
|
|
|
* |
625
|
|
|
* @return string |
626
|
|
|
*/ |
627
|
|
|
public function getEmail() |
628
|
|
|
{ |
629
|
|
|
$contact = $this->getRelatedContact(); |
630
|
|
|
if (!$contact) { |
631
|
|
|
return null; |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
return $contact->getEmail(); |
635
|
|
|
} |
636
|
|
|
|
637
|
|
|
/** |
638
|
|
|
* @ORM\PrePersist |
639
|
|
|
*/ |
640
|
|
|
public function prePersist() |
641
|
|
|
{ |
642
|
|
|
$this->createdAt = $this->createdAt ? $this->createdAt : new \DateTime('now', new \DateTimeZone('UTC')); |
643
|
|
|
$this->reportedAt = $this->reportedAt? $this->reportedAt : new \DateTime('now', new \DateTimeZone('UTC')); |
644
|
|
|
if ($this->updateClosedAt && !$this->closedAt) { |
645
|
|
|
$this->setClosedAt(new \DateTime('now', new \DateTimeZone('UTC'))); |
646
|
|
|
} |
647
|
|
|
} |
648
|
|
|
|
649
|
|
|
/** |
650
|
|
|
* @ORM\PreUpdate |
651
|
|
|
*/ |
652
|
|
|
public function preUpdate() |
653
|
|
|
{ |
654
|
|
|
$this->updatedAt = new \DateTime('now', new \DateTimeZone('UTC')); |
655
|
|
|
if ($this->updateClosedAt) { |
656
|
|
|
$this->setClosedAt(new \DateTime('now', new \DateTimeZone('UTC'))); |
657
|
|
|
} |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* @return string |
662
|
|
|
*/ |
663
|
|
|
public function __toString() |
664
|
|
|
{ |
665
|
|
|
return (string)$this->subject; |
666
|
|
|
} |
667
|
|
|
|
668
|
|
|
/** |
669
|
|
|
* Set organization |
670
|
|
|
* |
671
|
|
|
* @param Organization $organization |
672
|
|
|
* @return CaseEntity |
673
|
|
|
*/ |
674
|
|
|
public function setOrganization(Organization $organization = null) |
675
|
|
|
{ |
676
|
|
|
$this->organization = $organization; |
677
|
|
|
|
678
|
|
|
return $this; |
679
|
|
|
} |
680
|
|
|
|
681
|
|
|
/** |
682
|
|
|
* Get organization |
683
|
|
|
* |
684
|
|
|
* @return Organization |
685
|
|
|
*/ |
686
|
|
|
public function getOrganization() |
687
|
|
|
{ |
688
|
|
|
return $this->organization; |
689
|
|
|
} |
690
|
|
|
} |
691
|
|
|
|