1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Oro\Bundle\ContactBundle\Entity; |
4
|
|
|
|
5
|
|
|
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
8
|
|
|
use Doctrine\Common\Collections\Collection; |
9
|
|
|
use Doctrine\ORM\Mapping as ORM; |
10
|
|
|
|
11
|
|
|
use Oro\Bundle\AddressBundle\Entity\AbstractAddress; |
12
|
|
|
use Oro\Bundle\AddressBundle\Entity\AddressType; |
13
|
|
|
use Oro\Bundle\BusinessEntitiesBundle\Entity\BasePerson; |
14
|
|
|
use Oro\Bundle\EmailBundle\Entity\EmailOwnerInterface; |
15
|
|
|
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config; |
16
|
|
|
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField; |
17
|
|
|
use Oro\Bundle\OrganizationBundle\Entity\Organization; |
18
|
|
|
use Oro\Bundle\UserBundle\Entity\User; |
19
|
|
|
use Oro\Bundle\AccountBundle\Entity\Account; |
20
|
|
|
use Oro\Bundle\ContactBundle\Model\ExtendContact; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @SuppressWarnings(PHPMD.TooManyMethods) |
24
|
|
|
* @SuppressWarnings(PHPMD.ExcessivePublicCount) |
25
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) |
26
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveClassLength) |
27
|
|
|
* @SuppressWarnings(PHPMD.TooManyFields) |
28
|
|
|
* |
29
|
|
|
* @ORM\Entity(repositoryClass="Oro\Bundle\ContactBundle\Entity\Repository\ContactRepository") |
30
|
|
|
* @ORM\Table( |
31
|
|
|
* name="orocrm_contact", |
32
|
|
|
* indexes={ |
33
|
|
|
* @ORM\Index(name="contact_name_idx",columns={"last_name", "first_name"}), |
34
|
|
|
* @ORM\Index(name="contact_updated_at_idx",columns={"updatedAt"}), |
35
|
|
|
* } |
36
|
|
|
* ) |
37
|
|
|
* @ORM\HasLifecycleCallbacks() |
38
|
|
|
* @Config( |
39
|
|
|
* routeName="oro_contact_index", |
40
|
|
|
* routeView="oro_contact_view", |
41
|
|
|
* defaultValues={ |
42
|
|
|
* "entity"={ |
43
|
|
|
* "icon"="icon-group", |
44
|
|
|
* "contact_information"={ |
45
|
|
|
* "email"={ |
46
|
|
|
* {"fieldName"="primaryEmail"} |
47
|
|
|
* }, |
48
|
|
|
* "phone"={ |
49
|
|
|
* {"fieldName"="primaryPhone"} |
50
|
|
|
* } |
51
|
|
|
* } |
52
|
|
|
* }, |
53
|
|
|
* "ownership"={ |
54
|
|
|
* "owner_type"="USER", |
55
|
|
|
* "owner_field_name"="owner", |
56
|
|
|
* "owner_column_name"="user_owner_id", |
57
|
|
|
* "organization_field_name"="organization", |
58
|
|
|
* "organization_column_name"="organization_id" |
59
|
|
|
* }, |
60
|
|
|
* "security"={ |
61
|
|
|
* "type"="ACL", |
62
|
|
|
* "group_name"="", |
63
|
|
|
* "category"="account_management" |
64
|
|
|
* }, |
65
|
|
|
* "form"={ |
66
|
|
|
* "form_type"="oro_contact_select", |
67
|
|
|
* "grid_name"="contacts-select-grid", |
68
|
|
|
* }, |
69
|
|
|
* "dataaudit"={ |
70
|
|
|
* "auditable"=true |
71
|
|
|
* }, |
72
|
|
|
* "grid"={ |
73
|
|
|
* "default"="contacts-grid", |
74
|
|
|
* "context"="contacts-for-context-grid" |
75
|
|
|
* }, |
76
|
|
|
* "tag"={ |
77
|
|
|
* "enabled"=true |
78
|
|
|
* }, |
79
|
|
|
* "merge"={ |
80
|
|
|
* "enable"=true |
81
|
|
|
* } |
82
|
|
|
* } |
83
|
|
|
* ) |
84
|
|
|
*/ |
85
|
|
|
class Contact extends ExtendContact implements EmailOwnerInterface |
86
|
|
|
{ |
87
|
|
|
/* |
88
|
|
|
* Fields have to be duplicated here to enable dataaudit and soap transformation only for contact |
89
|
|
|
*/ |
90
|
|
|
/** |
91
|
|
|
* @var int |
92
|
|
|
* |
93
|
|
|
* @ORM\Id |
94
|
|
|
* @ORM\Column(type="integer", name="id") |
95
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
96
|
|
|
* @Soap\ComplexType("int", nillable=true) |
97
|
|
|
* @ConfigField( |
98
|
|
|
* defaultValues={ |
99
|
|
|
* "importexport"={ |
100
|
|
|
* "order"=10 |
101
|
|
|
* } |
102
|
|
|
* } |
103
|
|
|
* ) |
104
|
|
|
*/ |
105
|
|
|
protected $id; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @var string |
109
|
|
|
* |
110
|
|
|
* @ORM\Column(name="name_prefix", type="string", length=255, nullable=true) |
111
|
|
|
* @Soap\ComplexType("string", nillable=true) |
112
|
|
|
* @ConfigField( |
113
|
|
|
* defaultValues={ |
114
|
|
|
* "dataaudit"={ |
115
|
|
|
* "auditable"=true |
116
|
|
|
* }, |
117
|
|
|
* "importexport"={ |
118
|
|
|
* "order"=20 |
119
|
|
|
* }, |
120
|
|
|
* "merge"={ |
121
|
|
|
* "display"=true |
122
|
|
|
* } |
123
|
|
|
* } |
124
|
|
|
* ) |
125
|
|
|
*/ |
126
|
|
|
protected $namePrefix; |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @var string |
130
|
|
|
* |
131
|
|
|
* @ORM\Column(name="first_name", type="string", length=255, nullable=true) |
132
|
|
|
* @Soap\ComplexType("string", nillable=true) |
133
|
|
|
* @ConfigField( |
134
|
|
|
* defaultValues={ |
135
|
|
|
* "dataaudit"={ |
136
|
|
|
* "auditable"=true |
137
|
|
|
* }, |
138
|
|
|
* "importexport"={ |
139
|
|
|
* "identity"=true, |
140
|
|
|
* "order"=30 |
141
|
|
|
* }, |
142
|
|
|
* "merge"={ |
143
|
|
|
* "display"=true |
144
|
|
|
* } |
145
|
|
|
* } |
146
|
|
|
* ) |
147
|
|
|
*/ |
148
|
|
|
protected $firstName; |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @var string |
152
|
|
|
* |
153
|
|
|
* @ORM\Column(name="middle_name", type="string", length=255, nullable=true) |
154
|
|
|
* @Soap\ComplexType("string", nillable=true) |
155
|
|
|
* @ConfigField( |
156
|
|
|
* defaultValues={ |
157
|
|
|
* "dataaudit"={ |
158
|
|
|
* "auditable"=true |
159
|
|
|
* }, |
160
|
|
|
* "importexport"={ |
161
|
|
|
* "order"=40 |
162
|
|
|
* }, |
163
|
|
|
* "merge"={ |
164
|
|
|
* "display"=true |
165
|
|
|
* } |
166
|
|
|
* } |
167
|
|
|
* ) |
168
|
|
|
*/ |
169
|
|
|
protected $middleName; |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @var string |
173
|
|
|
* |
174
|
|
|
* @ORM\Column(name="last_name", type="string", length=255, nullable=true) |
175
|
|
|
* @Soap\ComplexType("string", nillable=true) |
176
|
|
|
* @ConfigField( |
177
|
|
|
* defaultValues={ |
178
|
|
|
* "dataaudit"={ |
179
|
|
|
* "auditable"=true |
180
|
|
|
* }, |
181
|
|
|
* "importexport"={ |
182
|
|
|
* "identity"=true, |
183
|
|
|
* "order"=50 |
184
|
|
|
* }, |
185
|
|
|
* "merge"={ |
186
|
|
|
* "display"=true |
187
|
|
|
* } |
188
|
|
|
* } |
189
|
|
|
* ) |
190
|
|
|
*/ |
191
|
|
|
protected $lastName; |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @var string |
195
|
|
|
* |
196
|
|
|
* @ORM\Column(name="name_suffix", type="string", length=255, nullable=true) |
197
|
|
|
* @Soap\ComplexType("string", nillable=true) |
198
|
|
|
* @ConfigField( |
199
|
|
|
* defaultValues={ |
200
|
|
|
* "dataaudit"={ |
201
|
|
|
* "auditable"=true |
202
|
|
|
* }, |
203
|
|
|
* "importexport"={ |
204
|
|
|
* "order"=60 |
205
|
|
|
* }, |
206
|
|
|
* "merge"={ |
207
|
|
|
* "display"=true |
208
|
|
|
* } |
209
|
|
|
* } |
210
|
|
|
* ) |
211
|
|
|
*/ |
212
|
|
|
protected $nameSuffix; |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @var string |
216
|
|
|
* |
217
|
|
|
* @ORM\Column(name="gender", type="string", length=8, nullable=true) |
218
|
|
|
* @Soap\ComplexType("string", nillable=true) |
219
|
|
|
* @ConfigField( |
220
|
|
|
* defaultValues={ |
221
|
|
|
* "dataaudit"={ |
222
|
|
|
* "auditable"=true |
223
|
|
|
* }, |
224
|
|
|
* "importexport"={ |
225
|
|
|
* "order"=70 |
226
|
|
|
* }, |
227
|
|
|
* "merge"={ |
228
|
|
|
* "display"=true |
229
|
|
|
* } |
230
|
|
|
* } |
231
|
|
|
* ) |
232
|
|
|
*/ |
233
|
|
|
protected $gender; |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @var \DateTime |
237
|
|
|
* |
238
|
|
|
* @ORM\Column(name="birthday", type="date", nullable=true) |
239
|
|
|
* @Soap\ComplexType("date", nillable=true) |
240
|
|
|
* @ConfigField( |
241
|
|
|
* defaultValues={ |
242
|
|
|
* "dataaudit"={ |
243
|
|
|
* "auditable"=true |
244
|
|
|
* }, |
245
|
|
|
* "importexport"={ |
246
|
|
|
* "order"=160 |
247
|
|
|
* }, |
248
|
|
|
* "merge"={ |
249
|
|
|
* "display"=true |
250
|
|
|
* } |
251
|
|
|
* } |
252
|
|
|
* ) |
253
|
|
|
*/ |
254
|
|
|
protected $birthday; |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @var string |
258
|
|
|
* |
259
|
|
|
* @ORM\Column(name="description", type="text", nullable=true) |
260
|
|
|
* @Soap\ComplexType("string", nillable=true) |
261
|
|
|
* @ConfigField( |
262
|
|
|
* defaultValues={ |
263
|
|
|
* "dataaudit"={ |
264
|
|
|
* "auditable"=true |
265
|
|
|
* }, |
266
|
|
|
* "importexport"={ |
267
|
|
|
* "order"=80 |
268
|
|
|
* }, |
269
|
|
|
* "merge"={ |
270
|
|
|
* "display"=true, |
271
|
|
|
* "autoescape"=false |
272
|
|
|
* } |
273
|
|
|
* } |
274
|
|
|
* ) |
275
|
|
|
*/ |
276
|
|
|
protected $description; |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* @var Source |
280
|
|
|
* |
281
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\ContactBundle\Entity\Source") |
282
|
|
|
* @ORM\JoinColumn(name="source_name", referencedColumnName="name") |
283
|
|
|
* @ConfigField( |
284
|
|
|
* defaultValues={ |
285
|
|
|
* "dataaudit"={ |
286
|
|
|
* "auditable"=true |
287
|
|
|
* }, |
288
|
|
|
* "importexport"={ |
289
|
|
|
* "order"=170 |
290
|
|
|
* }, |
291
|
|
|
* "merge"={ |
292
|
|
|
* "display"=true |
293
|
|
|
* } |
294
|
|
|
* } |
295
|
|
|
* ) |
296
|
|
|
**/ |
297
|
|
|
protected $source; |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* @var Method |
301
|
|
|
* |
302
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\ContactBundle\Entity\Method") |
303
|
|
|
* @ORM\JoinColumn(name="method_name", referencedColumnName="name") |
304
|
|
|
* @ConfigField( |
305
|
|
|
* defaultValues={ |
306
|
|
|
* "dataaudit"={ |
307
|
|
|
* "auditable"=true |
308
|
|
|
* }, |
309
|
|
|
* "importexport"={ |
310
|
|
|
* "order"=180 |
311
|
|
|
* }, |
312
|
|
|
* "merge"={ |
313
|
|
|
* "display"=true |
314
|
|
|
* } |
315
|
|
|
* } |
316
|
|
|
* ) |
317
|
|
|
**/ |
318
|
|
|
protected $method; |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* @var User |
322
|
|
|
* |
323
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
324
|
|
|
* @ORM\JoinColumn(name="user_owner_id", referencedColumnName="id", onDelete="SET NULL") |
325
|
|
|
* @Soap\ComplexType("string", nillable=true) |
326
|
|
|
* @ConfigField( |
327
|
|
|
* defaultValues={ |
328
|
|
|
* "dataaudit"={ |
329
|
|
|
* "auditable"=true |
330
|
|
|
* }, |
331
|
|
|
* "importexport"={ |
332
|
|
|
* "order"=190, |
333
|
|
|
* "short"=true |
334
|
|
|
* }, |
335
|
|
|
* "merge"={ |
336
|
|
|
* "display"=true |
337
|
|
|
* } |
338
|
|
|
* } |
339
|
|
|
* ) |
340
|
|
|
*/ |
341
|
|
|
protected $owner; |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* @var User |
345
|
|
|
* |
346
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
347
|
|
|
* @ORM\JoinColumn(name="assigned_to_user_id", referencedColumnName="id", onDelete="SET NULL") |
348
|
|
|
* @ConfigField( |
349
|
|
|
* defaultValues={ |
350
|
|
|
* "dataaudit"={ |
351
|
|
|
* "auditable"=true |
352
|
|
|
* }, |
353
|
|
|
* "importexport"={ |
354
|
|
|
* "order"=200, |
355
|
|
|
* "short"=true |
356
|
|
|
* }, |
357
|
|
|
* "merge"={ |
358
|
|
|
* "display"=true |
359
|
|
|
* } |
360
|
|
|
* } |
361
|
|
|
* ) |
362
|
|
|
*/ |
363
|
|
|
protected $assignedTo; |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* @var Contact |
367
|
|
|
* |
368
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\ContactBundle\Entity\Contact") |
369
|
|
|
* @ORM\JoinColumn(name="reports_to_contact_id", referencedColumnName="id", onDelete="SET NULL") |
370
|
|
|
* @ConfigField( |
371
|
|
|
* defaultValues={ |
372
|
|
|
* "dataaudit"={ |
373
|
|
|
* "auditable"=true |
374
|
|
|
* }, |
375
|
|
|
* "importexport"={ |
376
|
|
|
* "excluded"=true |
377
|
|
|
* }, |
378
|
|
|
* "merge"={ |
379
|
|
|
* "display"=true |
380
|
|
|
* } |
381
|
|
|
* } |
382
|
|
|
* ) |
383
|
|
|
*/ |
384
|
|
|
protected $reportsTo; |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* @var string |
388
|
|
|
* |
389
|
|
|
* @ORM\Column(name="job_title", type="string", length=255, nullable=true) |
390
|
|
|
* @Soap\ComplexType("string", nillable=true) |
391
|
|
|
* @ConfigField( |
392
|
|
|
* defaultValues={ |
393
|
|
|
* "dataaudit"={ |
394
|
|
|
* "auditable"=true |
395
|
|
|
* }, |
396
|
|
|
* "importexport"={ |
397
|
|
|
* "order"=90 |
398
|
|
|
* }, |
399
|
|
|
* "merge"={ |
400
|
|
|
* "display"=true |
401
|
|
|
* } |
402
|
|
|
* } |
403
|
|
|
* ) |
404
|
|
|
*/ |
405
|
|
|
protected $jobTitle; |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* @var string |
409
|
|
|
* |
410
|
|
|
* @ORM\Column(name="email", type="string", length=255, nullable=true) |
411
|
|
|
* @ConfigField( |
412
|
|
|
* defaultValues={ |
413
|
|
|
* "dataaudit"={ |
414
|
|
|
* "auditable"=true |
415
|
|
|
* }, |
416
|
|
|
* "entity"={ |
417
|
|
|
* "contact_information"="email" |
418
|
|
|
* } |
419
|
|
|
* } |
420
|
|
|
* ) |
421
|
|
|
*/ |
422
|
|
|
protected $email; |
423
|
|
|
|
424
|
|
|
/** |
425
|
|
|
* @var Collection |
426
|
|
|
* |
427
|
|
|
* @ORM\OneToMany(targetEntity="Oro\Bundle\ContactBundle\Entity\ContactEmail", |
428
|
|
|
* mappedBy="owner", cascade={"all"}, orphanRemoval=true |
429
|
|
|
* ) |
430
|
|
|
* @ORM\OrderBy({"primary" = "DESC"}) |
431
|
|
|
* @Soap\ComplexType("Oro\Bundle\ContactBundle\Entity\ContactEmail[]", nillable=true) |
432
|
|
|
* @ConfigField( |
433
|
|
|
* defaultValues={ |
434
|
|
|
* "importexport"={ |
435
|
|
|
* "order"=210 |
436
|
|
|
* }, |
437
|
|
|
* "dataaudit"={ |
438
|
|
|
* "auditable"=true |
439
|
|
|
* }, |
440
|
|
|
* "merge"={ |
441
|
|
|
* "display"=true |
442
|
|
|
* } |
443
|
|
|
* } |
444
|
|
|
* ) |
445
|
|
|
*/ |
446
|
|
|
protected $emails; |
447
|
|
|
|
448
|
|
|
/** |
449
|
|
|
* @var Collection |
450
|
|
|
* |
451
|
|
|
* @ORM\OneToMany(targetEntity="Oro\Bundle\ContactBundle\Entity\ContactPhone", mappedBy="owner", |
452
|
|
|
* mappedBy="owner", cascade={"all"}, orphanRemoval=true |
453
|
|
|
* )) |
454
|
|
|
* @ORM\OrderBy({"primary" = "DESC"}) |
455
|
|
|
* @Soap\ComplexType("Oro\Bundle\ContactBundle\Entity\ContactPhone[]", nillable=true) |
456
|
|
|
* @ConfigField( |
457
|
|
|
* defaultValues={ |
458
|
|
|
* "importexport"={ |
459
|
|
|
* "order"=220 |
460
|
|
|
* }, |
461
|
|
|
* "dataaudit"={ |
462
|
|
|
* "auditable"=true |
463
|
|
|
* }, |
464
|
|
|
* "merge"={ |
465
|
|
|
* "display"=true |
466
|
|
|
* } |
467
|
|
|
* } |
468
|
|
|
* ) |
469
|
|
|
*/ |
470
|
|
|
protected $phones; |
471
|
|
|
|
472
|
|
|
/** |
473
|
|
|
* @var string |
474
|
|
|
* |
475
|
|
|
* @ORM\Column(name="fax", type="string", length=255, nullable=true) |
476
|
|
|
* @Soap\ComplexType("string", nillable=true) |
477
|
|
|
* @ConfigField( |
478
|
|
|
* defaultValues={ |
479
|
|
|
* "dataaudit"={ |
480
|
|
|
* "auditable"=true |
481
|
|
|
* }, |
482
|
|
|
* "importexport"={ |
483
|
|
|
* "order"=100 |
484
|
|
|
* }, |
485
|
|
|
* "merge"={ |
486
|
|
|
* "display"=true |
487
|
|
|
* } |
488
|
|
|
* } |
489
|
|
|
* ) |
490
|
|
|
*/ |
491
|
|
|
protected $fax; |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* @var string |
495
|
|
|
* |
496
|
|
|
* @ORM\Column(name="skype", type="string", length=255, nullable=true) |
497
|
|
|
* @Soap\ComplexType("string", nillable=true) |
498
|
|
|
* @ConfigField( |
499
|
|
|
* defaultValues={ |
500
|
|
|
* "dataaudit"={ |
501
|
|
|
* "auditable"=true |
502
|
|
|
* }, |
503
|
|
|
* "importexport"={ |
504
|
|
|
* "order"=110 |
505
|
|
|
* }, |
506
|
|
|
* "merge"={ |
507
|
|
|
* "display"=true |
508
|
|
|
* } |
509
|
|
|
* } |
510
|
|
|
* ) |
511
|
|
|
*/ |
512
|
|
|
protected $skype; |
513
|
|
|
|
514
|
|
|
/** |
515
|
|
|
* @var string |
516
|
|
|
* |
517
|
|
|
* @ORM\Column(name="twitter", type="string", length=255, nullable=true) |
518
|
|
|
* @Soap\ComplexType("string", nillable=true) |
519
|
|
|
* @ConfigField( |
520
|
|
|
* defaultValues={ |
521
|
|
|
* "dataaudit"={ |
522
|
|
|
* "auditable"=true |
523
|
|
|
* }, |
524
|
|
|
* "importexport"={ |
525
|
|
|
* "order"=120 |
526
|
|
|
* }, |
527
|
|
|
* "merge"={ |
528
|
|
|
* "display"=true |
529
|
|
|
* } |
530
|
|
|
* } |
531
|
|
|
* ) |
532
|
|
|
*/ |
533
|
|
|
protected $twitter; |
534
|
|
|
|
535
|
|
|
/** |
536
|
|
|
* @var string |
537
|
|
|
* |
538
|
|
|
* @ORM\Column(name="facebook", type="string", length=255, nullable=true) |
539
|
|
|
* @Soap\ComplexType("string", nillable=true) |
540
|
|
|
* @ConfigField( |
541
|
|
|
* defaultValues={ |
542
|
|
|
* "dataaudit"={ |
543
|
|
|
* "auditable"=true |
544
|
|
|
* }, |
545
|
|
|
* "importexport"={ |
546
|
|
|
* "order"=130 |
547
|
|
|
* }, |
548
|
|
|
* "merge"={ |
549
|
|
|
* "display"=true |
550
|
|
|
* } |
551
|
|
|
* } |
552
|
|
|
* ) |
553
|
|
|
*/ |
554
|
|
|
protected $facebook; |
555
|
|
|
|
556
|
|
|
/** |
557
|
|
|
* @var string |
558
|
|
|
* |
559
|
|
|
* @ORM\Column(name="google_plus", type="string", length=255, nullable=true) |
560
|
|
|
* @Soap\ComplexType("string", nillable=true) |
561
|
|
|
* @ConfigField( |
562
|
|
|
* defaultValues={ |
563
|
|
|
* "dataaudit"={ |
564
|
|
|
* "auditable"=true |
565
|
|
|
* }, |
566
|
|
|
* "importexport"={ |
567
|
|
|
* "order"=140 |
568
|
|
|
* }, |
569
|
|
|
* "merge"={ |
570
|
|
|
* "display"=true |
571
|
|
|
* } |
572
|
|
|
* } |
573
|
|
|
* ) |
574
|
|
|
*/ |
575
|
|
|
protected $googlePlus; |
576
|
|
|
|
577
|
|
|
/** |
578
|
|
|
* @var string |
579
|
|
|
* |
580
|
|
|
* @ORM\Column(name="linkedin", type="string", length=255, nullable=true) |
581
|
|
|
* @Soap\ComplexType("string", nillable=true) |
582
|
|
|
* @ConfigField( |
583
|
|
|
* defaultValues={ |
584
|
|
|
* "dataaudit"={ |
585
|
|
|
* "auditable"=true |
586
|
|
|
* }, |
587
|
|
|
* "importexport"={ |
588
|
|
|
* "order"=150 |
589
|
|
|
* }, |
590
|
|
|
* "merge"={ |
591
|
|
|
* "display"=true |
592
|
|
|
* } |
593
|
|
|
* } |
594
|
|
|
* ) |
595
|
|
|
*/ |
596
|
|
|
protected $linkedIn; |
597
|
|
|
|
598
|
|
|
/** |
599
|
|
|
* @var Collection |
600
|
|
|
* |
601
|
|
|
* @ORM\OneToMany(targetEntity="Oro\Bundle\ContactBundle\Entity\ContactAddress", |
602
|
|
|
* mappedBy="owner", cascade={"all"}, orphanRemoval=true |
603
|
|
|
* ) |
604
|
|
|
* @ORM\OrderBy({"primary" = "DESC"}) |
605
|
|
|
* @ConfigField( |
606
|
|
|
* defaultValues={ |
607
|
|
|
* "importexport"={ |
608
|
|
|
* "full"=true, |
609
|
|
|
* "order"=250 |
610
|
|
|
* }, |
611
|
|
|
* "dataaudit"={ |
612
|
|
|
* "auditable"=true |
613
|
|
|
* }, |
614
|
|
|
* "merge"={ |
615
|
|
|
* "display"=true |
616
|
|
|
* } |
617
|
|
|
* } |
618
|
|
|
* ) |
619
|
|
|
*/ |
620
|
|
|
protected $addresses; |
621
|
|
|
|
622
|
|
|
/** |
623
|
|
|
* @var Collection |
624
|
|
|
* |
625
|
|
|
* @ORM\ManyToMany(targetEntity="Oro\Bundle\ContactBundle\Entity\Group") |
626
|
|
|
* @ORM\JoinTable(name="orocrm_contact_to_contact_grp", |
627
|
|
|
* joinColumns={@ORM\JoinColumn(name="contact_id", referencedColumnName="id", onDelete="CASCADE")}, |
628
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="contact_group_id", referencedColumnName="id", onDelete="CASCADE")} |
629
|
|
|
* ) |
630
|
|
|
* @ConfigField( |
631
|
|
|
* defaultValues={ |
632
|
|
|
* "importexport"={ |
633
|
|
|
* "order"=230, |
634
|
|
|
* "short"=true |
635
|
|
|
* }, |
636
|
|
|
* "merge"={ |
637
|
|
|
* "display"=true |
638
|
|
|
* } |
639
|
|
|
* } |
640
|
|
|
* ) |
641
|
|
|
*/ |
642
|
|
|
protected $groups; |
643
|
|
|
|
644
|
|
|
/** |
645
|
|
|
* @var Collection |
646
|
|
|
* |
647
|
|
|
* @ORM\ManyToMany(targetEntity="Oro\Bundle\AccountBundle\Entity\Account", mappedBy="contacts") |
648
|
|
|
* @ORM\JoinTable(name="orocrm_account_to_contact") |
649
|
|
|
* @ConfigField( |
650
|
|
|
* defaultValues={ |
651
|
|
|
* "importexport"={ |
652
|
|
|
* "order"=240, |
653
|
|
|
* "short"=true |
654
|
|
|
* }, |
655
|
|
|
* "merge"={ |
656
|
|
|
* "display"=true |
657
|
|
|
* } |
658
|
|
|
* } |
659
|
|
|
* ) |
660
|
|
|
*/ |
661
|
|
|
protected $accounts; |
662
|
|
|
|
663
|
|
|
/** |
664
|
|
|
* @var User |
665
|
|
|
* |
666
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
667
|
|
|
* @ORM\JoinColumn(name="created_by_user_id", referencedColumnName="id", onDelete="SET NULL") |
668
|
|
|
* @ConfigField( |
669
|
|
|
* defaultValues={ |
670
|
|
|
* "importexport"={ |
671
|
|
|
* "excluded"=true |
672
|
|
|
* } |
673
|
|
|
* } |
674
|
|
|
* ) |
675
|
|
|
*/ |
676
|
|
|
protected $createdBy; |
677
|
|
|
|
678
|
|
|
/** |
679
|
|
|
* @var User |
680
|
|
|
* |
681
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
682
|
|
|
* @ORM\JoinColumn(name="updated_by_user_id", referencedColumnName="id", onDelete="SET NULL") |
683
|
|
|
* @ConfigField( |
684
|
|
|
* defaultValues={ |
685
|
|
|
* "importexport"={ |
686
|
|
|
* "excluded"=true |
687
|
|
|
* } |
688
|
|
|
* } |
689
|
|
|
* ) |
690
|
|
|
*/ |
691
|
|
|
protected $updatedBy; |
692
|
|
|
|
693
|
|
|
/** |
694
|
|
|
* @var \DateTime $created |
695
|
|
|
* |
696
|
|
|
* @ORM\Column(type="datetime") |
697
|
|
|
* @Soap\ComplexType("dateTime", nillable=true) |
698
|
|
|
* @ConfigField( |
699
|
|
|
* defaultValues={ |
700
|
|
|
* "entity"={ |
701
|
|
|
* "label"="oro.ui.created_at" |
702
|
|
|
* }, |
703
|
|
|
* "importexport"={ |
704
|
|
|
* "excluded"=true |
705
|
|
|
* } |
706
|
|
|
* } |
707
|
|
|
* ) |
708
|
|
|
*/ |
709
|
|
|
protected $createdAt; |
710
|
|
|
|
711
|
|
|
/** |
712
|
|
|
* @var \DateTime $updated |
713
|
|
|
* |
714
|
|
|
* @ORM\Column(type="datetime") |
715
|
|
|
* @Soap\ComplexType("dateTime", nillable=true) |
716
|
|
|
* @ConfigField( |
717
|
|
|
* defaultValues={ |
718
|
|
|
* "entity"={ |
719
|
|
|
* "label"="oro.ui.updated_at" |
720
|
|
|
* }, |
721
|
|
|
* "importexport"={ |
722
|
|
|
* "excluded"=true |
723
|
|
|
* } |
724
|
|
|
* } |
725
|
|
|
* ) |
726
|
|
|
*/ |
727
|
|
|
protected $updatedAt; |
728
|
|
|
|
729
|
|
|
/** |
730
|
|
|
* @var Organization |
731
|
|
|
* |
732
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization") |
733
|
|
|
* @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL") |
734
|
|
|
*/ |
735
|
|
|
protected $organization; |
736
|
|
|
|
737
|
|
|
/** |
738
|
|
|
* @var Account[]|Collection |
739
|
|
|
* |
740
|
|
|
* @ORM\OneToMany(targetEntity="Oro\Bundle\AccountBundle\Entity\Account", |
741
|
|
|
* mappedBy="defaultContact", cascade={"persist"} |
742
|
|
|
* ) |
743
|
|
|
* @ConfigField( |
744
|
|
|
* defaultValues={ |
745
|
|
|
* "importexport"={ |
746
|
|
|
* "order"=240 |
747
|
|
|
* } |
748
|
|
|
* } |
749
|
|
|
* ) |
750
|
|
|
*/ |
751
|
|
|
protected $defaultInAccounts; |
752
|
|
|
|
753
|
|
|
public function __construct() |
754
|
|
|
{ |
755
|
|
|
parent::__construct(); |
756
|
|
|
|
757
|
|
|
$this->groups = new ArrayCollection(); |
758
|
|
|
$this->accounts = new ArrayCollection(); |
759
|
|
|
$this->emails = new ArrayCollection(); |
760
|
|
|
$this->phones = new ArrayCollection(); |
761
|
|
|
$this->defaultInAccounts = new ArrayCollection(); |
762
|
|
|
} |
763
|
|
|
|
764
|
|
|
public function __clone() |
765
|
|
|
{ |
766
|
|
|
parent::__clone(); |
767
|
|
|
|
768
|
|
|
if ($this->groups) { |
769
|
|
|
$this->groups = clone $this->groups; |
770
|
|
|
} |
771
|
|
|
if ($this->accounts) { |
772
|
|
|
$this->accounts = clone $this->accounts; |
773
|
|
|
} |
774
|
|
|
if ($this->emails) { |
775
|
|
|
$this->emails = clone $this->emails; |
776
|
|
|
} |
777
|
|
|
if ($this->phones) { |
778
|
|
|
$this->phones = clone $this->phones; |
779
|
|
|
} |
780
|
|
|
if ($this->defaultInAccounts) { |
781
|
|
|
$this->defaultInAccounts = clone $this->defaultInAccounts; |
782
|
|
|
} |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
/** |
786
|
|
|
* Get entity class name. |
787
|
|
|
* TODO: Remove this temporary solution for get 'view' route in twig after EntityConfigBundle is finished |
788
|
|
|
* @return string |
789
|
|
|
*/ |
790
|
|
|
public function getClass() |
791
|
|
|
{ |
792
|
|
|
return 'Oro\Bundle\ContactBundle\Entity\Contact'; |
793
|
|
|
} |
794
|
|
|
|
795
|
|
|
/** |
796
|
|
|
* Get names of fields contain email addresses |
797
|
|
|
* |
798
|
|
|
* @return string[]|null |
799
|
|
|
*/ |
800
|
|
|
public function getEmailFields() |
801
|
|
|
{ |
802
|
|
|
return null; |
803
|
|
|
} |
804
|
|
|
|
805
|
|
|
/** |
806
|
|
|
* @param User $assignedTo |
807
|
|
|
* |
808
|
|
|
* @return Contact |
809
|
|
|
*/ |
810
|
|
|
public function setAssignedTo($assignedTo) |
811
|
|
|
{ |
812
|
|
|
$this->assignedTo = $assignedTo; |
813
|
|
|
|
814
|
|
|
return $this; |
815
|
|
|
} |
816
|
|
|
|
817
|
|
|
/** |
818
|
|
|
* @return User |
819
|
|
|
*/ |
820
|
|
|
public function getAssignedTo() |
821
|
|
|
{ |
822
|
|
|
return $this->assignedTo; |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
/** |
826
|
|
|
* @param string $description |
827
|
|
|
* |
828
|
|
|
* @return Contact |
829
|
|
|
*/ |
830
|
|
|
public function setDescription($description) |
831
|
|
|
{ |
832
|
|
|
$this->description = $description; |
833
|
|
|
|
834
|
|
|
return $this; |
835
|
|
|
} |
836
|
|
|
|
837
|
|
|
/** |
838
|
|
|
* @return string |
839
|
|
|
*/ |
840
|
|
|
public function getDescription() |
841
|
|
|
{ |
842
|
|
|
return $this->description; |
843
|
|
|
} |
844
|
|
|
|
845
|
|
|
/** |
846
|
|
|
* @param Source $source |
847
|
|
|
* |
848
|
|
|
* @return Contact |
849
|
|
|
*/ |
850
|
|
|
public function setSource($source) |
851
|
|
|
{ |
852
|
|
|
$this->source = $source; |
853
|
|
|
|
854
|
|
|
return $this; |
855
|
|
|
} |
856
|
|
|
|
857
|
|
|
/** |
858
|
|
|
* @return Source |
859
|
|
|
*/ |
860
|
|
|
public function getSource() |
861
|
|
|
{ |
862
|
|
|
return $this->source; |
863
|
|
|
} |
864
|
|
|
|
865
|
|
|
/** |
866
|
|
|
* @param Method $method |
867
|
|
|
* |
868
|
|
|
* @return Contact |
869
|
|
|
*/ |
870
|
|
|
public function setMethod($method) |
871
|
|
|
{ |
872
|
|
|
$this->method = $method; |
873
|
|
|
|
874
|
|
|
return $this; |
875
|
|
|
} |
876
|
|
|
|
877
|
|
|
/** |
878
|
|
|
* @return Method |
879
|
|
|
*/ |
880
|
|
|
public function getMethod() |
881
|
|
|
{ |
882
|
|
|
return $this->method; |
883
|
|
|
} |
884
|
|
|
|
885
|
|
|
/** |
886
|
|
|
* @param User $owningUser |
887
|
|
|
* |
888
|
|
|
* @return Contact |
889
|
|
|
*/ |
890
|
|
|
public function setOwner($owningUser) |
891
|
|
|
{ |
892
|
|
|
$this->owner = $owningUser; |
893
|
|
|
|
894
|
|
|
return $this; |
895
|
|
|
} |
896
|
|
|
|
897
|
|
|
/** |
898
|
|
|
* @return User |
899
|
|
|
*/ |
900
|
|
|
public function getOwner() |
901
|
|
|
{ |
902
|
|
|
return $this->owner; |
903
|
|
|
} |
904
|
|
|
|
905
|
|
|
/** |
906
|
|
|
* @param Contact $reportsTo |
907
|
|
|
* |
908
|
|
|
* @return Contact |
909
|
|
|
*/ |
910
|
|
|
public function setReportsTo($reportsTo) |
911
|
|
|
{ |
912
|
|
|
$this->reportsTo = $reportsTo; |
913
|
|
|
|
914
|
|
|
return $this; |
915
|
|
|
} |
916
|
|
|
|
917
|
|
|
/** |
918
|
|
|
* @return Contact |
919
|
|
|
*/ |
920
|
|
|
public function getReportsTo() |
921
|
|
|
{ |
922
|
|
|
return $this->reportsTo; |
923
|
|
|
} |
924
|
|
|
|
925
|
|
|
/** |
926
|
|
|
* @param string $jobTitle |
927
|
|
|
* |
928
|
|
|
* @return Contact |
929
|
|
|
*/ |
930
|
|
|
public function setJobTitle($jobTitle) |
931
|
|
|
{ |
932
|
|
|
$this->jobTitle = $jobTitle; |
933
|
|
|
|
934
|
|
|
return $this; |
935
|
|
|
} |
936
|
|
|
|
937
|
|
|
/** |
938
|
|
|
* @return string |
939
|
|
|
*/ |
940
|
|
|
public function getJobTitle() |
941
|
|
|
{ |
942
|
|
|
return $this->jobTitle; |
943
|
|
|
} |
944
|
|
|
|
945
|
|
|
/** |
946
|
|
|
* @param string $fax |
947
|
|
|
* |
948
|
|
|
* @return Contact |
949
|
|
|
*/ |
950
|
|
|
public function setFax($fax) |
951
|
|
|
{ |
952
|
|
|
$this->fax = $fax; |
953
|
|
|
|
954
|
|
|
return $this; |
955
|
|
|
} |
956
|
|
|
|
957
|
|
|
/** |
958
|
|
|
* @return string |
959
|
|
|
*/ |
960
|
|
|
public function getFax() |
961
|
|
|
{ |
962
|
|
|
return $this->fax; |
963
|
|
|
} |
964
|
|
|
|
965
|
|
|
/** |
966
|
|
|
* @param string $skype |
967
|
|
|
* |
968
|
|
|
* @return Contact |
969
|
|
|
*/ |
970
|
|
|
public function setSkype($skype) |
971
|
|
|
{ |
972
|
|
|
$this->skype = $skype; |
973
|
|
|
|
974
|
|
|
return $this; |
975
|
|
|
} |
976
|
|
|
|
977
|
|
|
/** |
978
|
|
|
* @return string |
979
|
|
|
*/ |
980
|
|
|
public function getSkype() |
981
|
|
|
{ |
982
|
|
|
return $this->skype; |
983
|
|
|
} |
984
|
|
|
|
985
|
|
|
/** |
986
|
|
|
* @param string $facebookUrl |
987
|
|
|
* |
988
|
|
|
* @return Contact |
989
|
|
|
*/ |
990
|
|
|
public function setFacebook($facebookUrl) |
991
|
|
|
{ |
992
|
|
|
$this->facebook = $facebookUrl; |
993
|
|
|
|
994
|
|
|
return $this; |
995
|
|
|
} |
996
|
|
|
|
997
|
|
|
/** |
998
|
|
|
* @return string |
999
|
|
|
*/ |
1000
|
|
|
public function getFacebook() |
1001
|
|
|
{ |
1002
|
|
|
return $this->facebook; |
1003
|
|
|
} |
1004
|
|
|
|
1005
|
|
|
/** |
1006
|
|
|
* @param string $googlePlusUrl |
1007
|
|
|
* |
1008
|
|
|
* @return Contact |
1009
|
|
|
*/ |
1010
|
|
|
public function setGooglePlus($googlePlusUrl) |
1011
|
|
|
{ |
1012
|
|
|
$this->googlePlus = $googlePlusUrl; |
1013
|
|
|
|
1014
|
|
|
return $this; |
1015
|
|
|
} |
1016
|
|
|
|
1017
|
|
|
/** |
1018
|
|
|
* @return string |
1019
|
|
|
*/ |
1020
|
|
|
public function getGooglePlus() |
1021
|
|
|
{ |
1022
|
|
|
return $this->googlePlus; |
1023
|
|
|
} |
1024
|
|
|
|
1025
|
|
|
/** |
1026
|
|
|
* @param string $linkedInUrl |
1027
|
|
|
* |
1028
|
|
|
* @return Contact |
1029
|
|
|
*/ |
1030
|
|
|
public function setLinkedIn($linkedInUrl) |
1031
|
|
|
{ |
1032
|
|
|
$this->linkedIn = $linkedInUrl; |
1033
|
|
|
|
1034
|
|
|
return $this; |
1035
|
|
|
} |
1036
|
|
|
|
1037
|
|
|
/** |
1038
|
|
|
* @return string |
1039
|
|
|
*/ |
1040
|
|
|
public function getLinkedIn() |
1041
|
|
|
{ |
1042
|
|
|
return $this->linkedIn; |
1043
|
|
|
} |
1044
|
|
|
|
1045
|
|
|
/** |
1046
|
|
|
* @param string $twitterUrl |
1047
|
|
|
* |
1048
|
|
|
* @return Contact |
1049
|
|
|
*/ |
1050
|
|
|
public function setTwitter($twitterUrl) |
1051
|
|
|
{ |
1052
|
|
|
$this->twitter = $twitterUrl; |
1053
|
|
|
|
1054
|
|
|
return $this; |
1055
|
|
|
} |
1056
|
|
|
|
1057
|
|
|
/** |
1058
|
|
|
* @return string |
1059
|
|
|
*/ |
1060
|
|
|
public function getTwitter() |
1061
|
|
|
{ |
1062
|
|
|
return $this->twitter; |
1063
|
|
|
} |
1064
|
|
|
|
1065
|
|
|
/** |
1066
|
|
|
* Set emails. |
1067
|
|
|
* |
1068
|
|
|
* This method could not be named setEmails because of bug CRM-253. |
1069
|
|
|
* |
1070
|
|
|
* @param Collection|ContactEmail[] $emails |
1071
|
|
|
* |
1072
|
|
|
* @return Contact |
1073
|
|
|
*/ |
1074
|
|
|
public function resetEmails($emails) |
1075
|
|
|
{ |
1076
|
|
|
$this->emails->clear(); |
1077
|
|
|
|
1078
|
|
|
foreach ($emails as $email) { |
1079
|
|
|
$this->addEmail($email); |
1080
|
|
|
} |
1081
|
|
|
|
1082
|
|
|
return $this; |
1083
|
|
|
} |
1084
|
|
|
|
1085
|
|
|
/** |
1086
|
|
|
* Add email |
1087
|
|
|
* |
1088
|
|
|
* @param ContactEmail $email |
1089
|
|
|
* |
1090
|
|
|
* @return Contact |
1091
|
|
|
*/ |
1092
|
|
|
public function addEmail(ContactEmail $email) |
1093
|
|
|
{ |
1094
|
|
View Code Duplication |
if (!$this->emails->contains($email)) { |
|
|
|
|
1095
|
|
|
//don't allow more than one primary email |
1096
|
|
|
if ($email->isPrimary() && $this->getPrimaryEmail()) { |
1097
|
|
|
$email->setPrimary(false); |
1098
|
|
|
} |
1099
|
|
|
|
1100
|
|
|
$this->emails->add($email); |
1101
|
|
|
$email->setOwner($this); |
1102
|
|
|
} |
1103
|
|
|
|
1104
|
|
|
return $this; |
1105
|
|
|
} |
1106
|
|
|
|
1107
|
|
|
/** |
1108
|
|
|
* Remove email |
1109
|
|
|
* |
1110
|
|
|
* @param ContactEmail $email |
1111
|
|
|
* |
1112
|
|
|
* @return Contact |
1113
|
|
|
*/ |
1114
|
|
|
public function removeEmail(ContactEmail $email) |
1115
|
|
|
{ |
1116
|
|
|
if ($this->emails->contains($email)) { |
1117
|
|
|
$this->emails->removeElement($email); |
1118
|
|
|
} |
1119
|
|
|
|
1120
|
|
|
return $this; |
1121
|
|
|
} |
1122
|
|
|
|
1123
|
|
|
/** |
1124
|
|
|
* Get emails |
1125
|
|
|
* |
1126
|
|
|
* @return Collection|ContactEmail[] |
1127
|
|
|
*/ |
1128
|
|
|
public function getEmails() |
1129
|
|
|
{ |
1130
|
|
|
return $this->emails; |
1131
|
|
|
} |
1132
|
|
|
|
1133
|
|
|
/** |
1134
|
|
|
* {@inheritdoc} |
1135
|
|
|
*/ |
1136
|
|
|
public function getEmail() |
1137
|
|
|
{ |
1138
|
|
|
$primaryEmail = $this->getPrimaryEmail(); |
1139
|
|
|
if (!$primaryEmail) { |
1140
|
|
|
return null; |
1141
|
|
|
} |
1142
|
|
|
|
1143
|
|
|
return $primaryEmail->getEmail(); |
1144
|
|
|
} |
1145
|
|
|
|
1146
|
|
|
/** |
1147
|
|
|
* @param ContactEmail $email |
1148
|
|
|
* @return bool |
1149
|
|
|
*/ |
1150
|
|
|
public function hasEmail(ContactEmail $email) |
1151
|
|
|
{ |
1152
|
|
|
return $this->getEmails()->contains($email); |
1153
|
|
|
} |
1154
|
|
|
|
1155
|
|
|
/** |
1156
|
|
|
* Gets primary email if it's available. |
1157
|
|
|
* |
1158
|
|
|
* @return ContactEmail|null |
1159
|
|
|
*/ |
1160
|
|
View Code Duplication |
public function getPrimaryEmail() |
|
|
|
|
1161
|
|
|
{ |
1162
|
|
|
$result = null; |
1163
|
|
|
|
1164
|
|
|
foreach ($this->getEmails() as $email) { |
1165
|
|
|
if ($email->isPrimary()) { |
1166
|
|
|
$result = $email; |
1167
|
|
|
break; |
1168
|
|
|
} |
1169
|
|
|
} |
1170
|
|
|
|
1171
|
|
|
return $result; |
1172
|
|
|
} |
1173
|
|
|
|
1174
|
|
|
/** |
1175
|
|
|
* @param ContactEmail $email |
1176
|
|
|
* @return Contact |
1177
|
|
|
*/ |
1178
|
|
View Code Duplication |
public function setPrimaryEmail(ContactEmail $email) |
|
|
|
|
1179
|
|
|
{ |
1180
|
|
|
if ($this->hasEmail($email)) { |
1181
|
|
|
$email->setPrimary(true); |
1182
|
|
|
foreach ($this->getEmails() as $otherEmail) { |
1183
|
|
|
if (!$email->isEqual($otherEmail)) { |
1184
|
|
|
$otherEmail->setPrimary(false); |
1185
|
|
|
} |
1186
|
|
|
} |
1187
|
|
|
} |
1188
|
|
|
|
1189
|
|
|
return $this; |
1190
|
|
|
} |
1191
|
|
|
|
1192
|
|
|
/** |
1193
|
|
|
* Set phones. |
1194
|
|
|
* |
1195
|
|
|
* This method could not be named setPhones because of bug CRM-253. |
1196
|
|
|
* |
1197
|
|
|
* @param Collection|ContactPhone[] $phones |
1198
|
|
|
* |
1199
|
|
|
* @return Contact |
1200
|
|
|
*/ |
1201
|
|
|
public function resetPhones($phones) |
1202
|
|
|
{ |
1203
|
|
|
$this->phones->clear(); |
1204
|
|
|
|
1205
|
|
|
foreach ($phones as $phone) { |
1206
|
|
|
$this->addPhone($phone); |
1207
|
|
|
} |
1208
|
|
|
|
1209
|
|
|
return $this; |
1210
|
|
|
} |
1211
|
|
|
|
1212
|
|
|
/** |
1213
|
|
|
* Add phone |
1214
|
|
|
* |
1215
|
|
|
* @param ContactPhone $phone |
1216
|
|
|
* |
1217
|
|
|
* @return Contact |
1218
|
|
|
*/ |
1219
|
|
|
public function addPhone(ContactPhone $phone) |
1220
|
|
|
{ |
1221
|
|
View Code Duplication |
if (!$this->phones->contains($phone)) { |
|
|
|
|
1222
|
|
|
//don't allow more than one primary phone |
1223
|
|
|
if ($phone->isPrimary() && $this->getPrimaryPhone()) { |
1224
|
|
|
$phone->setPrimary(false); |
1225
|
|
|
} |
1226
|
|
|
|
1227
|
|
|
$this->phones->add($phone); |
1228
|
|
|
$phone->setOwner($this); |
1229
|
|
|
} |
1230
|
|
|
|
1231
|
|
|
return $this; |
1232
|
|
|
} |
1233
|
|
|
|
1234
|
|
|
/** |
1235
|
|
|
* Remove phone |
1236
|
|
|
* |
1237
|
|
|
* @param ContactPhone $phone |
1238
|
|
|
* |
1239
|
|
|
* @return Contact |
1240
|
|
|
*/ |
1241
|
|
|
public function removePhone(ContactPhone $phone) |
1242
|
|
|
{ |
1243
|
|
|
if ($this->phones->contains($phone)) { |
1244
|
|
|
$this->phones->removeElement($phone); |
1245
|
|
|
} |
1246
|
|
|
|
1247
|
|
|
return $this; |
1248
|
|
|
} |
1249
|
|
|
|
1250
|
|
|
/** |
1251
|
|
|
* Get phones |
1252
|
|
|
* |
1253
|
|
|
* @return Collection|ContactPhone[] |
1254
|
|
|
*/ |
1255
|
|
|
public function getPhones() |
1256
|
|
|
{ |
1257
|
|
|
return $this->phones; |
1258
|
|
|
} |
1259
|
|
|
|
1260
|
|
|
/** |
1261
|
|
|
* @param ContactPhone $phone |
1262
|
|
|
* @return bool |
1263
|
|
|
*/ |
1264
|
|
|
public function hasPhone(ContactPhone $phone) |
1265
|
|
|
{ |
1266
|
|
|
return $this->getPhones()->contains($phone); |
1267
|
|
|
} |
1268
|
|
|
|
1269
|
|
|
/** |
1270
|
|
|
* Gets primary phone if it's available. |
1271
|
|
|
* |
1272
|
|
|
* @return ContactPhone|null |
1273
|
|
|
*/ |
1274
|
|
View Code Duplication |
public function getPrimaryPhone() |
|
|
|
|
1275
|
|
|
{ |
1276
|
|
|
$result = null; |
1277
|
|
|
|
1278
|
|
|
foreach ($this->getPhones() as $phone) { |
1279
|
|
|
if ($phone->isPrimary()) { |
1280
|
|
|
$result = $phone; |
1281
|
|
|
break; |
1282
|
|
|
} |
1283
|
|
|
} |
1284
|
|
|
|
1285
|
|
|
return $result; |
1286
|
|
|
} |
1287
|
|
|
|
1288
|
|
|
/** |
1289
|
|
|
* @param ContactPhone $phone |
1290
|
|
|
* @return Contact |
1291
|
|
|
*/ |
1292
|
|
View Code Duplication |
public function setPrimaryPhone(ContactPhone $phone) |
|
|
|
|
1293
|
|
|
{ |
1294
|
|
|
if ($this->hasPhone($phone)) { |
1295
|
|
|
$phone->setPrimary(true); |
1296
|
|
|
foreach ($this->getPhones() as $otherPhone) { |
1297
|
|
|
if (!$phone->isEqual($otherPhone)) { |
1298
|
|
|
$otherPhone->setPrimary(false); |
1299
|
|
|
} |
1300
|
|
|
} |
1301
|
|
|
} |
1302
|
|
|
|
1303
|
|
|
return $this; |
1304
|
|
|
} |
1305
|
|
|
|
1306
|
|
|
/** |
1307
|
|
|
* Add address |
1308
|
|
|
* |
1309
|
|
|
* @param AbstractAddress $address |
1310
|
|
|
* |
1311
|
|
|
* @return BasePerson |
1312
|
|
|
*/ |
1313
|
|
|
public function addAddress(AbstractAddress $address) |
1314
|
|
|
{ |
1315
|
|
|
/** @var ContactAddress $address */ |
1316
|
|
View Code Duplication |
if (!$this->addresses->contains($address)) { |
|
|
|
|
1317
|
|
|
//don't allow more than one primary address |
1318
|
|
|
if ($address->isPrimary() && $this->getPrimaryAddress()) { |
1319
|
|
|
$address->setPrimary(false); |
1320
|
|
|
} |
1321
|
|
|
|
1322
|
|
|
$this->addresses->add($address); |
1323
|
|
|
$address->setOwner($this); |
1324
|
|
|
} |
1325
|
|
|
|
1326
|
|
|
return $this; |
1327
|
|
|
} |
1328
|
|
|
|
1329
|
|
|
/** |
1330
|
|
|
* Gets primary address if it's available. |
1331
|
|
|
* |
1332
|
|
|
* @return ContactAddress|null |
1333
|
|
|
*/ |
1334
|
|
View Code Duplication |
public function getPrimaryAddress() |
|
|
|
|
1335
|
|
|
{ |
1336
|
|
|
$result = null; |
1337
|
|
|
|
1338
|
|
|
/** @var ContactAddress $address */ |
1339
|
|
|
foreach ($this->getAddresses() as $address) { |
1340
|
|
|
if ($address->isPrimary()) { |
1341
|
|
|
$result = $address; |
1342
|
|
|
break; |
1343
|
|
|
} |
1344
|
|
|
} |
1345
|
|
|
|
1346
|
|
|
return $result; |
1347
|
|
|
} |
1348
|
|
|
|
1349
|
|
|
/** |
1350
|
|
|
* @param ContactAddress $address |
1351
|
|
|
* |
1352
|
|
|
* @return Contact |
1353
|
|
|
*/ |
1354
|
|
View Code Duplication |
public function setPrimaryAddress(ContactAddress $address) |
|
|
|
|
1355
|
|
|
{ |
1356
|
|
|
if ($this->hasAddress($address)) { |
1357
|
|
|
$address->setPrimary(true); |
1358
|
|
|
/** @var ContactAddress $otherAddress */ |
1359
|
|
|
foreach ($this->getAddresses() as $otherAddress) { |
1360
|
|
|
if (!$address->isEqual($otherAddress)) { |
1361
|
|
|
$otherAddress->setPrimary(false); |
1362
|
|
|
} |
1363
|
|
|
} |
1364
|
|
|
} |
1365
|
|
|
|
1366
|
|
|
return $this; |
1367
|
|
|
} |
1368
|
|
|
|
1369
|
|
|
/** |
1370
|
|
|
* Gets address type if it's available. |
1371
|
|
|
* |
1372
|
|
|
* @param ContactAddress $address |
1373
|
|
|
* @param AddressType $addressType |
1374
|
|
|
* |
1375
|
|
|
* @return Contact |
1376
|
|
|
*/ |
1377
|
|
View Code Duplication |
public function setAddressType(ContactAddress $address, AddressType $addressType) |
|
|
|
|
1378
|
|
|
{ |
1379
|
|
|
if ($this->hasAddress($address)) { |
1380
|
|
|
$address->addType($addressType); |
1381
|
|
|
/** @var ContactAddress $otherAddress */ |
1382
|
|
|
foreach ($this->getAddresses() as $otherAddress) { |
1383
|
|
|
if (!$address->isEqual($otherAddress)) { |
1384
|
|
|
$otherAddress->removeType($addressType); |
1385
|
|
|
} |
1386
|
|
|
} |
1387
|
|
|
} |
1388
|
|
|
|
1389
|
|
|
return $this; |
1390
|
|
|
} |
1391
|
|
|
|
1392
|
|
|
/** |
1393
|
|
|
* Gets one address that has specified type. |
1394
|
|
|
* |
1395
|
|
|
* @param AddressType $type |
1396
|
|
|
* |
1397
|
|
|
* @return ContactAddress|null |
1398
|
|
|
*/ |
1399
|
|
|
public function getAddressByType(AddressType $type) |
1400
|
|
|
{ |
1401
|
|
|
return $this->getAddressByTypeName($type->getName()); |
1402
|
|
|
} |
1403
|
|
|
|
1404
|
|
|
/** |
1405
|
|
|
* Gets one address that has specified type name. |
1406
|
|
|
* |
1407
|
|
|
* @param string $typeName |
1408
|
|
|
* |
1409
|
|
|
* @return ContactAddress|null |
1410
|
|
|
*/ |
1411
|
|
|
public function getAddressByTypeName($typeName) |
1412
|
|
|
{ |
1413
|
|
|
$result = null; |
1414
|
|
|
|
1415
|
|
|
/** @var ContactAddress $address */ |
1416
|
|
|
foreach ($this->getAddresses() as $address) { |
1417
|
|
|
if ($address->hasTypeWithName($typeName)) { |
1418
|
|
|
$result = $address; |
1419
|
|
|
break; |
1420
|
|
|
} |
1421
|
|
|
} |
1422
|
|
|
|
1423
|
|
|
return $result; |
1424
|
|
|
} |
1425
|
|
|
|
1426
|
|
|
/** |
1427
|
|
|
* Get group labels separated with comma. |
1428
|
|
|
* |
1429
|
|
|
* @return string |
1430
|
|
|
*/ |
1431
|
|
|
public function getGroupLabelsAsString() |
1432
|
|
|
{ |
1433
|
|
|
return implode(', ', $this->getGroupLabels()); |
1434
|
|
|
} |
1435
|
|
|
|
1436
|
|
|
/** |
1437
|
|
|
* Get list of group labels |
1438
|
|
|
* |
1439
|
|
|
* @return array |
1440
|
|
|
*/ |
1441
|
|
|
public function getGroupLabels() |
1442
|
|
|
{ |
1443
|
|
|
$result = []; |
1444
|
|
|
|
1445
|
|
|
/** @var Group $group */ |
1446
|
|
|
foreach ($this->getGroups() as $group) { |
1447
|
|
|
$result[] = $group->getLabel(); |
1448
|
|
|
} |
1449
|
|
|
|
1450
|
|
|
return $result; |
1451
|
|
|
} |
1452
|
|
|
|
1453
|
|
|
/** |
1454
|
|
|
* Gets the groups related to contact |
1455
|
|
|
* |
1456
|
|
|
* @return Group[]|Collection |
1457
|
|
|
*/ |
1458
|
|
|
public function getGroups() |
1459
|
|
|
{ |
1460
|
|
|
return $this->groups; |
1461
|
|
|
} |
1462
|
|
|
|
1463
|
|
|
/** |
1464
|
|
|
* Add specified group |
1465
|
|
|
* |
1466
|
|
|
* @param Group $group |
1467
|
|
|
* |
1468
|
|
|
* @return Contact |
1469
|
|
|
*/ |
1470
|
|
|
public function addGroup(Group $group) |
1471
|
|
|
{ |
1472
|
|
|
if (!$this->getGroups()->contains($group)) { |
1473
|
|
|
$this->getGroups()->add($group); |
1474
|
|
|
} |
1475
|
|
|
|
1476
|
|
|
return $this; |
1477
|
|
|
} |
1478
|
|
|
|
1479
|
|
|
/** |
1480
|
|
|
* Remove specified group |
1481
|
|
|
* |
1482
|
|
|
* @param Group $group |
1483
|
|
|
* |
1484
|
|
|
* @return Contact |
1485
|
|
|
*/ |
1486
|
|
|
public function removeGroup(Group $group) |
1487
|
|
|
{ |
1488
|
|
|
if ($this->getGroups()->contains($group)) { |
1489
|
|
|
$this->getGroups()->removeElement($group); |
1490
|
|
|
} |
1491
|
|
|
|
1492
|
|
|
return $this; |
1493
|
|
|
} |
1494
|
|
|
|
1495
|
|
|
/** |
1496
|
|
|
* Get accounts collection |
1497
|
|
|
* |
1498
|
|
|
* @return Collection|Account[] |
1499
|
|
|
*/ |
1500
|
|
|
public function getAccounts() |
1501
|
|
|
{ |
1502
|
|
|
return $this->accounts; |
1503
|
|
|
} |
1504
|
|
|
|
1505
|
|
|
/** |
1506
|
|
|
* Add specified account |
1507
|
|
|
* |
1508
|
|
|
* @param Account $account |
1509
|
|
|
* |
1510
|
|
|
* @return Contact |
1511
|
|
|
*/ |
1512
|
|
|
public function addAccount(Account $account) |
1513
|
|
|
{ |
1514
|
|
|
if (!$this->getAccounts()->contains($account)) { |
1515
|
|
|
$this->getAccounts()->add($account); |
1516
|
|
|
$account->addContact($this); |
1517
|
|
|
} |
1518
|
|
|
|
1519
|
|
|
return $this; |
1520
|
|
|
} |
1521
|
|
|
|
1522
|
|
|
/** |
1523
|
|
|
* Remove specified account |
1524
|
|
|
* |
1525
|
|
|
* @param Account $account |
1526
|
|
|
* |
1527
|
|
|
* @return Contact |
1528
|
|
|
*/ |
1529
|
|
|
public function removeAccount(Account $account) |
1530
|
|
|
{ |
1531
|
|
|
if ($this->getAccounts()->contains($account)) { |
1532
|
|
|
$this->getAccounts()->removeElement($account); |
1533
|
|
|
$account->removeContact($this); |
1534
|
|
|
} |
1535
|
|
|
|
1536
|
|
|
return $this; |
1537
|
|
|
} |
1538
|
|
|
|
1539
|
|
|
/** |
1540
|
|
|
* @return bool |
1541
|
|
|
*/ |
1542
|
|
|
public function hasAccounts() |
1543
|
|
|
{ |
1544
|
|
|
return count($this->accounts) > 0; |
1545
|
|
|
} |
1546
|
|
|
|
1547
|
|
|
/** |
1548
|
|
|
* @param \Oro\Bundle\UserBundle\Entity\User $createdBy |
1549
|
|
|
* |
1550
|
|
|
* @return Contact |
1551
|
|
|
*/ |
1552
|
|
|
public function setCreatedBy($createdBy) |
1553
|
|
|
{ |
1554
|
|
|
$this->createdBy = $createdBy; |
1555
|
|
|
|
1556
|
|
|
return $this; |
1557
|
|
|
} |
1558
|
|
|
|
1559
|
|
|
/** |
1560
|
|
|
* @return \Oro\Bundle\UserBundle\Entity\User |
1561
|
|
|
*/ |
1562
|
|
|
public function getCreatedBy() |
1563
|
|
|
{ |
1564
|
|
|
return $this->createdBy; |
1565
|
|
|
} |
1566
|
|
|
|
1567
|
|
|
/** |
1568
|
|
|
* @param \Oro\Bundle\UserBundle\Entity\User $updatedBy |
1569
|
|
|
* |
1570
|
|
|
* @return Contact |
1571
|
|
|
*/ |
1572
|
|
|
public function setUpdatedBy($updatedBy) |
1573
|
|
|
{ |
1574
|
|
|
$this->updatedBy = $updatedBy; |
1575
|
|
|
|
1576
|
|
|
return $this; |
1577
|
|
|
} |
1578
|
|
|
|
1579
|
|
|
/** |
1580
|
|
|
* @return \Oro\Bundle\UserBundle\Entity\User |
1581
|
|
|
*/ |
1582
|
|
|
public function getUpdatedBy() |
1583
|
|
|
{ |
1584
|
|
|
return $this->updatedBy; |
1585
|
|
|
} |
1586
|
|
|
|
1587
|
|
|
/** |
1588
|
|
|
* @return string |
1589
|
|
|
*/ |
1590
|
|
|
public function __toString() |
1591
|
|
|
{ |
1592
|
|
|
$name = $this->getNamePrefix() . ' ' |
1593
|
|
|
. $this->getFirstName() . ' ' |
1594
|
|
|
. $this->getMiddleName() . ' ' |
1595
|
|
|
. $this->getLastName() . ' ' |
1596
|
|
|
. $this->getNameSuffix(); |
1597
|
|
|
$name = preg_replace('/ +/', ' ', $name); |
1598
|
|
|
|
1599
|
|
|
return (string)trim($name); |
1600
|
|
|
} |
1601
|
|
|
|
1602
|
|
|
/** |
1603
|
|
|
* Set organization |
1604
|
|
|
* |
1605
|
|
|
* @param Organization $organization |
1606
|
|
|
* @return Contact |
1607
|
|
|
*/ |
1608
|
|
|
public function setOrganization(Organization $organization = null) |
1609
|
|
|
{ |
1610
|
|
|
$this->organization = $organization; |
1611
|
|
|
|
1612
|
|
|
return $this; |
1613
|
|
|
} |
1614
|
|
|
|
1615
|
|
|
/** |
1616
|
|
|
* Get organization |
1617
|
|
|
* |
1618
|
|
|
* @return Organization |
1619
|
|
|
*/ |
1620
|
|
|
public function getOrganization() |
1621
|
|
|
{ |
1622
|
|
|
return $this->organization; |
1623
|
|
|
} |
1624
|
|
|
|
1625
|
|
|
/** |
1626
|
|
|
* @param Account $account |
1627
|
|
|
* |
1628
|
|
|
* @return $this |
1629
|
|
|
*/ |
1630
|
|
View Code Duplication |
public function addDefaultInAccount(Account $account) |
|
|
|
|
1631
|
|
|
{ |
1632
|
|
|
if (!$this->defaultInAccounts->contains($account)) { |
1633
|
|
|
$this->defaultInAccounts->add($account); |
1634
|
|
|
$account->setDefaultContact($this); |
1635
|
|
|
} |
1636
|
|
|
|
1637
|
|
|
return $this; |
1638
|
|
|
} |
1639
|
|
|
|
1640
|
|
|
/** |
1641
|
|
|
* @param Account $account |
1642
|
|
|
* |
1643
|
|
|
* @return $this |
1644
|
|
|
*/ |
1645
|
|
View Code Duplication |
public function removeDefaultInAccount(Account $account) |
|
|
|
|
1646
|
|
|
{ |
1647
|
|
|
$this->defaultInAccounts->removeElement($account); |
1648
|
|
|
if ($account->getDefaultContact() === $this) { |
1649
|
|
|
$account->setDefaultContact(null); |
|
|
|
|
1650
|
|
|
} |
1651
|
|
|
|
1652
|
|
|
return $this; |
1653
|
|
|
} |
1654
|
|
|
|
1655
|
|
|
/** |
1656
|
|
|
* @return Account[]|Collection |
1657
|
|
|
*/ |
1658
|
|
|
public function getDefaultInAccounts() |
1659
|
|
|
{ |
1660
|
|
|
return $this->defaultInAccounts; |
1661
|
|
|
} |
1662
|
|
|
} |
1663
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.