1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\MagentoBundle\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\AddressBundle\Entity\AbstractAddress; |
10
|
|
|
use Oro\Bundle\DataAuditBundle\Metadata\Annotation as Oro; |
11
|
|
|
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config; |
12
|
|
|
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField; |
13
|
|
|
use Oro\Bundle\OrganizationBundle\Entity\Organization; |
14
|
|
|
use Oro\Bundle\UserBundle\Entity\User; |
15
|
|
|
|
16
|
|
|
use OroCRM\Bundle\AccountBundle\Entity\Account; |
17
|
|
|
use OroCRM\Bundle\AnalyticsBundle\Model\RFMAwareInterface; |
18
|
|
|
use OroCRM\Bundle\AnalyticsBundle\Model\RFMAwareTrait; |
19
|
|
|
use OroCRM\Bundle\ContactBundle\Entity\Contact; |
20
|
|
|
use OroCRM\Bundle\MagentoBundle\Model\ExtendCustomer; |
21
|
|
|
use OroCRM\Bundle\ChannelBundle\Model\ChannelAwareInterface; |
22
|
|
|
use OroCRM\Bundle\ChannelBundle\Model\CustomerIdentityInterface; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class Customer |
26
|
|
|
* |
27
|
|
|
* @SuppressWarnings(PHPMD.TooManyFields) |
28
|
|
|
* @SuppressWarnings(PHPMD.ExcessivePublicCount) |
29
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) |
30
|
|
|
* |
31
|
|
|
* @package OroCRM\Bundle\OroCRMMagentoBundle\Entity |
32
|
|
|
* @ORM\Entity(repositoryClass="OroCRM\Bundle\MagentoBundle\Entity\Repository\CustomerRepository") |
33
|
|
|
* @ORM\Table( |
34
|
|
|
* name="orocrm_magento_customer", |
35
|
|
|
* uniqueConstraints={@ORM\UniqueConstraint(name="magecustomer_oid_cid_unq", columns={"origin_id", "channel_id"})}, |
36
|
|
|
* indexes={ |
37
|
|
|
* @ORM\Index(name="magecustomer_name_idx",columns={"first_name", "last_name"}), |
38
|
|
|
* @ORM\Index(name="magecustomer_rev_name_idx",columns={"last_name", "first_name"}), |
39
|
|
|
* @ORM\Index(name="magecustomer_email_guest_idx",columns={"email"}) |
40
|
|
|
* } |
41
|
|
|
* ) |
42
|
|
|
* @Config( |
43
|
|
|
* routeName="orocrm_magento_customer_index", |
44
|
|
|
* routeView="orocrm_magento_customer_view", |
45
|
|
|
* defaultValues={ |
46
|
|
|
* "entity"={ |
47
|
|
|
* "icon"="icon-user", |
48
|
|
|
* }, |
49
|
|
|
* "ownership"={ |
50
|
|
|
* "owner_type"="USER", |
51
|
|
|
* "owner_field_name"="owner", |
52
|
|
|
* "owner_column_name"="user_owner_id", |
53
|
|
|
* "organization_field_name"="organization", |
54
|
|
|
* "organization_column_name"="organization_id" |
55
|
|
|
* }, |
56
|
|
|
* "security"={ |
57
|
|
|
* "type"="ACL", |
58
|
|
|
* "group_name"="" |
59
|
|
|
* }, |
60
|
|
|
* "form"={ |
61
|
|
|
* "grid_name"="magento-customers-grid", |
62
|
|
|
* }, |
63
|
|
|
* "grid"={ |
64
|
|
|
* "default"="magento-customers-grid", |
65
|
|
|
* "context"="magento-customers-for-context-grid" |
66
|
|
|
* }, |
67
|
|
|
* "tag"={ |
68
|
|
|
* "enabled"=true |
69
|
|
|
* } |
70
|
|
|
* } |
71
|
|
|
* ) |
72
|
|
|
* @Oro\Loggable |
73
|
|
|
*/ |
74
|
|
|
class Customer extends ExtendCustomer implements |
75
|
|
|
ChannelAwareInterface, |
76
|
|
|
CustomerIdentityInterface, |
77
|
|
|
RFMAwareInterface, |
78
|
|
|
OriginAwareInterface, |
79
|
|
|
IntegrationAwareInterface |
80
|
|
|
{ |
81
|
|
|
const SYNC_TO_MAGENTO = 1; |
82
|
|
|
const MAGENTO_REMOVED = 2; |
83
|
|
|
|
84
|
|
|
use IntegrationEntityTrait, OriginTrait, ChannelEntityTrait, RFMAwareTrait; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var int |
88
|
|
|
* |
89
|
|
|
* @ORM\Id |
90
|
|
|
* @ORM\Column(type="integer", name="id") |
91
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
92
|
|
|
* @ConfigField( |
93
|
|
|
* defaultValues={ |
94
|
|
|
* "importexport"={ |
95
|
|
|
* "excluded"=true |
96
|
|
|
* } |
97
|
|
|
* } |
98
|
|
|
* ) |
99
|
|
|
*/ |
100
|
|
|
protected $id; |
101
|
|
|
|
102
|
|
|
/* |
103
|
|
|
* FIELDS are duplicated to enable dataaudit only for customer fields |
104
|
|
|
*/ |
105
|
|
|
/** |
106
|
|
|
* @var string |
107
|
|
|
* |
108
|
|
|
* @ORM\Column(name="name_prefix", type="string", length=255, nullable=true) |
109
|
|
|
* @Oro\Versioned |
110
|
|
|
*/ |
111
|
|
|
protected $namePrefix; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @var string |
115
|
|
|
* |
116
|
|
|
* @ORM\Column(name="first_name", type="string", length=255, nullable=true) |
117
|
|
|
* @Oro\Versioned |
118
|
|
|
*/ |
119
|
|
|
protected $firstName; |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @var string |
123
|
|
|
* |
124
|
|
|
* @ORM\Column(name="middle_name", type="string", length=255, nullable=true) |
125
|
|
|
* @Oro\Versioned |
126
|
|
|
*/ |
127
|
|
|
protected $middleName; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @var string |
131
|
|
|
* |
132
|
|
|
* @ORM\Column(name="last_name", type="string", length=255, nullable=true) |
133
|
|
|
* @Oro\Versioned |
134
|
|
|
*/ |
135
|
|
|
protected $lastName; |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @var string |
139
|
|
|
* |
140
|
|
|
* @ORM\Column(name="name_suffix", type="string", length=255, nullable=true) |
141
|
|
|
* @Oro\Versioned |
142
|
|
|
*/ |
143
|
|
|
protected $nameSuffix; |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @var string |
147
|
|
|
* |
148
|
|
|
* @ORM\Column(name="gender", type="string", length=8, nullable=true) |
149
|
|
|
* @Oro\Versioned |
150
|
|
|
*/ |
151
|
|
|
protected $gender; |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @var \DateTime |
155
|
|
|
* |
156
|
|
|
* @ORM\Column(name="birthday", type="date", nullable=true) |
157
|
|
|
* @Oro\Versioned |
158
|
|
|
*/ |
159
|
|
|
protected $birthday; |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @var string |
163
|
|
|
* |
164
|
|
|
* @ORM\Column(name="email", type="string", length=255, nullable=true) |
165
|
|
|
* @Oro\Versioned |
166
|
|
|
* @ConfigField( |
167
|
|
|
* defaultValues={ |
168
|
|
|
* "entity"={ |
169
|
|
|
* "contact_information"="email" |
170
|
|
|
* } |
171
|
|
|
* } |
172
|
|
|
* ) |
173
|
|
|
*/ |
174
|
|
|
protected $email; |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @var \DateTime $createdAt |
178
|
|
|
* |
179
|
|
|
* @ORM\Column(type="datetime", name="created_at") |
180
|
|
|
* @Oro\Versioned |
181
|
|
|
* @ConfigField( |
182
|
|
|
* defaultValues={ |
183
|
|
|
* "entity"={ |
184
|
|
|
* "label"="oro.ui.created_at" |
185
|
|
|
* } |
186
|
|
|
* } |
187
|
|
|
* ) |
188
|
|
|
*/ |
189
|
|
|
protected $createdAt; |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @var \DateTime $updatedAt |
193
|
|
|
* |
194
|
|
|
* @ORM\Column(type="datetime", name="updated_at") |
195
|
|
|
* @Oro\Versioned |
196
|
|
|
* @ConfigField( |
197
|
|
|
* defaultValues={ |
198
|
|
|
* "entity"={ |
199
|
|
|
* "label"="oro.ui.updated_at" |
200
|
|
|
* } |
201
|
|
|
* } |
202
|
|
|
* ) |
203
|
|
|
*/ |
204
|
|
|
protected $updatedAt; |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @var \DateTime |
208
|
|
|
* |
209
|
|
|
* @ORM\Column(type="datetime", name="imported_at", nullable=true) |
210
|
|
|
* @Oro\Versioned |
211
|
|
|
*/ |
212
|
|
|
protected $importedAt; |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @var \DateTime |
216
|
|
|
* |
217
|
|
|
* @ORM\Column(type="datetime", name="synced_at", nullable=true) |
218
|
|
|
* @Oro\Versioned |
219
|
|
|
*/ |
220
|
|
|
protected $syncedAt; |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* @var Website |
224
|
|
|
* |
225
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\Website") |
226
|
|
|
* @ORM\JoinColumn(name="website_id", referencedColumnName="id", onDelete="SET NULL") |
227
|
|
|
* @ConfigField( |
228
|
|
|
* defaultValues={ |
229
|
|
|
* "importexport"={ |
230
|
|
|
* "full"=false |
231
|
|
|
* } |
232
|
|
|
* } |
233
|
|
|
* ) |
234
|
|
|
*/ |
235
|
|
|
protected $website; |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @var Store |
239
|
|
|
* |
240
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\Store") |
241
|
|
|
* @ORM\JoinColumn(name="store_id", referencedColumnName="id", onDelete="SET NULL") |
242
|
|
|
* @ConfigField( |
243
|
|
|
* defaultValues={ |
244
|
|
|
* "importexport"={ |
245
|
|
|
* "full"=false |
246
|
|
|
* } |
247
|
|
|
* } |
248
|
|
|
* ) |
249
|
|
|
*/ |
250
|
|
|
protected $store; |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @var string |
254
|
|
|
* |
255
|
|
|
* @ORM\Column(name="created_in", type="string", length=255, nullable=true) |
256
|
|
|
* @Oro\Versioned |
257
|
|
|
*/ |
258
|
|
|
protected $createdIn; |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @var bool |
262
|
|
|
* @ORM\Column(name="is_confirmed", type="boolean", nullable=true) |
263
|
|
|
*/ |
264
|
|
|
protected $confirmed = true; |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* @var bool |
268
|
|
|
* @ORM\Column(name="is_guest", type="boolean", nullable=false, options={"default"=false}) |
269
|
|
|
*/ |
270
|
|
|
protected $guest = false; |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @var CustomerGroup |
274
|
|
|
* |
275
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\CustomerGroup") |
276
|
|
|
* @ORM\JoinColumn(name="customer_group_id", referencedColumnName="id", onDelete="SET NULL") |
277
|
|
|
* @ConfigField( |
278
|
|
|
* defaultValues={ |
279
|
|
|
* "importexport"={ |
280
|
|
|
* "full"=false |
281
|
|
|
* } |
282
|
|
|
* } |
283
|
|
|
* ) |
284
|
|
|
*/ |
285
|
|
|
protected $group; |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @var Contact |
289
|
|
|
* |
290
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\ContactBundle\Entity\Contact") |
291
|
|
|
* @ORM\JoinColumn(name="contact_id", referencedColumnName="id", onDelete="SET NULL") |
292
|
|
|
* @ConfigField( |
293
|
|
|
* defaultValues={ |
294
|
|
|
* "importexport"={ |
295
|
|
|
* "excluded"=true |
296
|
|
|
* } |
297
|
|
|
* } |
298
|
|
|
* ) |
299
|
|
|
*/ |
300
|
|
|
protected $contact; |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* @var Account |
304
|
|
|
* |
305
|
|
|
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\AccountBundle\Entity\Account") |
306
|
|
|
* @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="SET NULL") |
307
|
|
|
* @ConfigField( |
308
|
|
|
* defaultValues={ |
309
|
|
|
* "importexport"={ |
310
|
|
|
* "excluded"=true |
311
|
|
|
* } |
312
|
|
|
* } |
313
|
|
|
* ) |
314
|
|
|
*/ |
315
|
|
|
protected $account; |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* @var Collection |
319
|
|
|
* |
320
|
|
|
* @ORM\OneToMany(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\Address", |
321
|
|
|
* mappedBy="owner", cascade={"all"}, orphanRemoval=true |
322
|
|
|
* ) |
323
|
|
|
* @ORM\OrderBy({"primary" = "DESC"}) |
324
|
|
|
* @ConfigField( |
325
|
|
|
* defaultValues={ |
326
|
|
|
* "importexport"={ |
327
|
|
|
* "full"=true |
328
|
|
|
* } |
329
|
|
|
* } |
330
|
|
|
* ) |
331
|
|
|
*/ |
332
|
|
|
protected $addresses; |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @var Collection |
336
|
|
|
* |
337
|
|
|
* @ORM\OneToMany(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\Cart", |
338
|
|
|
* mappedBy="customer", cascade={"remove"}, orphanRemoval=true |
339
|
|
|
* ) |
340
|
|
|
* @ConfigField( |
341
|
|
|
* defaultValues={ |
342
|
|
|
* "importexport"={ |
343
|
|
|
* "excluded"=true |
344
|
|
|
* } |
345
|
|
|
* } |
346
|
|
|
* ) |
347
|
|
|
*/ |
348
|
|
|
protected $carts; |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* @var Collection |
352
|
|
|
* |
353
|
|
|
* @ORM\OneToMany(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\Order", |
354
|
|
|
* mappedBy="customer", cascade={"remove"}, orphanRemoval=true |
355
|
|
|
* ) |
356
|
|
|
* @ConfigField( |
357
|
|
|
* defaultValues={ |
358
|
|
|
* "importexport"={ |
359
|
|
|
* "excluded"=true |
360
|
|
|
* } |
361
|
|
|
* } |
362
|
|
|
* ) |
363
|
|
|
*/ |
364
|
|
|
protected $orders; |
365
|
|
|
|
366
|
|
|
/** |
367
|
|
|
* @var boolean |
368
|
|
|
* |
369
|
|
|
* @ORM\Column(type="boolean", name="is_active") |
370
|
|
|
* @ConfigField( |
371
|
|
|
* defaultValues={ |
372
|
|
|
* "importexport"={ |
373
|
|
|
* "excluded"=true |
374
|
|
|
* } |
375
|
|
|
* } |
376
|
|
|
* ) |
377
|
|
|
*/ |
378
|
|
|
protected $isActive = false; |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* @var float |
382
|
|
|
* |
383
|
|
|
* @ORM\Column(name="vat", type="string", length=255, nullable=true) |
384
|
|
|
* @Oro\Versioned |
385
|
|
|
*/ |
386
|
|
|
protected $vat; |
387
|
|
|
|
388
|
|
|
/** |
389
|
|
|
* @var float |
390
|
|
|
* |
391
|
|
|
* @ORM\Column(name="lifetime", type="money", nullable=true) |
392
|
|
|
* @ConfigField( |
393
|
|
|
* defaultValues={ |
394
|
|
|
* "importexport"={ |
395
|
|
|
* "excluded"=true |
396
|
|
|
* } |
397
|
|
|
* } |
398
|
|
|
* ) |
399
|
|
|
*/ |
400
|
|
|
protected $lifetime = 0; |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* @var string |
404
|
|
|
* |
405
|
|
|
* @ORM\Column(name="currency", type="string", length=10, nullable=true) |
406
|
|
|
* @ConfigField( |
407
|
|
|
* defaultValues={ |
408
|
|
|
* "importexport"={ |
409
|
|
|
* "excluded"=true |
410
|
|
|
* } |
411
|
|
|
* } |
412
|
|
|
* ) |
413
|
|
|
*/ |
414
|
|
|
protected $currency; |
415
|
|
|
|
416
|
|
|
/** |
417
|
|
|
* @var int |
418
|
|
|
* |
419
|
|
|
* @ORM\Column(name="sync_state", type="integer", nullable=true) |
420
|
|
|
* @ConfigField( |
421
|
|
|
* defaultValues={ |
422
|
|
|
* "importexport"={ |
423
|
|
|
* "excluded"=true |
424
|
|
|
* } |
425
|
|
|
* } |
426
|
|
|
* ) |
427
|
|
|
*/ |
428
|
|
|
protected $syncState; |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* @var User |
432
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
433
|
|
|
* @ORM\JoinColumn(name="user_owner_id", referencedColumnName="id", onDelete="SET NULL") |
434
|
|
|
* @ConfigField( |
435
|
|
|
* defaultValues={ |
436
|
|
|
* "importexport"={ |
437
|
|
|
* "excluded"=true |
438
|
|
|
* } |
439
|
|
|
* } |
440
|
|
|
* ) |
441
|
|
|
*/ |
442
|
|
|
protected $owner; |
443
|
|
|
|
444
|
|
|
/** |
445
|
|
|
* @var Organization |
446
|
|
|
* |
447
|
|
|
* @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization") |
448
|
|
|
* @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL") |
449
|
|
|
* @ConfigField( |
450
|
|
|
* defaultValues={ |
451
|
|
|
* "importexport"={ |
452
|
|
|
* "excluded"=true |
453
|
|
|
* } |
454
|
|
|
* } |
455
|
|
|
* ) |
456
|
|
|
*/ |
457
|
|
|
protected $organization; |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* @var string |
461
|
|
|
* |
462
|
|
|
* @ORM\Column(name="password", type="string", length=32, nullable=true) |
463
|
|
|
*/ |
464
|
|
|
protected $password; |
465
|
|
|
|
466
|
|
|
/** |
467
|
|
|
* @var NewsletterSubscriber[]|Collection |
468
|
|
|
* |
469
|
|
|
* @ORM\OneToMany(targetEntity="OroCRM\Bundle\MagentoBundle\Entity\NewsletterSubscriber", |
470
|
|
|
* mappedBy="customer", cascade={"remove"}, orphanRemoval=true) |
471
|
|
|
* @ConfigField( |
472
|
|
|
* defaultValues={ |
473
|
|
|
* "importexport"={ |
474
|
|
|
* "excluded"=true |
475
|
|
|
* } |
476
|
|
|
* } |
477
|
|
|
* ) |
478
|
|
|
*/ |
479
|
|
|
protected $newsletterSubscribers; |
480
|
|
|
|
481
|
|
|
/** |
482
|
|
|
* {@inheritdoc} |
483
|
|
|
*/ |
484
|
|
|
public function __construct() |
485
|
|
|
{ |
486
|
|
|
parent::__construct(); |
487
|
|
|
|
488
|
|
|
$this->carts = new ArrayCollection(); |
489
|
|
|
$this->orders = new ArrayCollection(); |
490
|
|
|
$this->newsletterSubscribers = new ArrayCollection(); |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* @param Website $website |
495
|
|
|
* |
496
|
|
|
* @return Customer |
497
|
|
|
*/ |
498
|
|
|
public function setWebsite(Website $website) |
499
|
|
|
{ |
500
|
|
|
$this->website = $website; |
501
|
|
|
|
502
|
|
|
return $this; |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
/** |
506
|
|
|
* @return Website |
507
|
|
|
*/ |
508
|
|
|
public function getWebsite() |
509
|
|
|
{ |
510
|
|
|
return $this->website; |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
/** |
514
|
|
|
* @return string |
515
|
|
|
*/ |
516
|
|
|
public function getWebsiteName() |
517
|
|
|
{ |
518
|
|
|
return $this->website ? $this->website->getName() : null; |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
/** |
522
|
|
|
* @param Store $store |
523
|
|
|
* |
524
|
|
|
* @return Customer |
525
|
|
|
*/ |
526
|
|
|
public function setStore(Store $store) |
527
|
|
|
{ |
528
|
|
|
$this->store = $store; |
529
|
|
|
|
530
|
|
|
return $this; |
531
|
|
|
} |
532
|
|
|
|
533
|
|
|
/** |
534
|
|
|
* @return Store |
535
|
|
|
*/ |
536
|
|
|
public function getStore() |
537
|
|
|
{ |
538
|
|
|
return $this->store; |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
/** |
542
|
|
|
* @return string|null |
543
|
|
|
*/ |
544
|
|
|
public function getStoreName() |
545
|
|
|
{ |
546
|
|
|
return $this->store ? $this->store->getName() : null; |
547
|
|
|
} |
548
|
|
|
|
549
|
|
|
/** |
550
|
|
|
* @return bool |
551
|
|
|
*/ |
552
|
|
|
public function isConfirmed() |
553
|
|
|
{ |
554
|
|
|
return $this->confirmed; |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
/** |
558
|
|
|
* @param bool $confirmed |
559
|
|
|
* @return Customer |
560
|
|
|
*/ |
561
|
|
|
public function setConfirmed($confirmed) |
562
|
|
|
{ |
563
|
|
|
$this->confirmed = $confirmed; |
564
|
|
|
|
565
|
|
|
return $this; |
566
|
|
|
} |
567
|
|
|
|
568
|
|
|
/** |
569
|
|
|
* @return bool |
570
|
|
|
*/ |
571
|
|
|
public function isGuest() |
572
|
|
|
{ |
573
|
|
|
return $this->guest; |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* @param bool $guest |
578
|
|
|
* @return Customer |
579
|
|
|
*/ |
580
|
|
|
public function setGuest($guest) |
581
|
|
|
{ |
582
|
|
|
$this->guest = $guest; |
583
|
|
|
|
584
|
|
|
return $this; |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* @return string |
589
|
|
|
*/ |
590
|
|
|
public function getCreatedIn() |
591
|
|
|
{ |
592
|
|
|
return $this->createdIn; |
593
|
|
|
} |
594
|
|
|
|
595
|
|
|
/** |
596
|
|
|
* @param string $createdIn |
597
|
|
|
* @return Customer |
598
|
|
|
*/ |
599
|
|
|
public function setCreatedIn($createdIn) |
600
|
|
|
{ |
601
|
|
|
$this->createdIn = $createdIn; |
602
|
|
|
|
603
|
|
|
return $this; |
604
|
|
|
} |
605
|
|
|
|
606
|
|
|
/** |
607
|
|
|
* @param CustomerGroup $group |
608
|
|
|
* |
609
|
|
|
* @return Customer |
610
|
|
|
*/ |
611
|
|
|
public function setGroup(CustomerGroup $group) |
612
|
|
|
{ |
613
|
|
|
$this->group = $group; |
614
|
|
|
|
615
|
|
|
return $this; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* @return CustomerGroup |
620
|
|
|
*/ |
621
|
|
|
public function getGroup() |
622
|
|
|
{ |
623
|
|
|
return $this->group; |
624
|
|
|
} |
625
|
|
|
|
626
|
|
|
/** |
627
|
|
|
* @param Contact $contact |
628
|
|
|
* |
629
|
|
|
* @return Customer |
630
|
|
|
*/ |
631
|
|
|
public function setContact($contact) |
632
|
|
|
{ |
633
|
|
|
$this->contact = $contact; |
634
|
|
|
|
635
|
|
|
return $this; |
636
|
|
|
} |
637
|
|
|
|
638
|
|
|
/** |
639
|
|
|
* @return Contact |
640
|
|
|
*/ |
641
|
|
|
public function getContact() |
642
|
|
|
{ |
643
|
|
|
return $this->contact; |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
/** |
647
|
|
|
* @param Account $account |
648
|
|
|
* |
649
|
|
|
* @return Customer |
650
|
|
|
*/ |
651
|
|
|
public function setAccount($account) |
652
|
|
|
{ |
653
|
|
|
$this->account = $account; |
654
|
|
|
|
655
|
|
|
return $this; |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
/** |
659
|
|
|
* @return Account |
660
|
|
|
*/ |
661
|
|
|
public function getAccount() |
662
|
|
|
{ |
663
|
|
|
return $this->account; |
664
|
|
|
} |
665
|
|
|
|
666
|
|
|
/** |
667
|
|
|
* @param string $vat |
668
|
|
|
* |
669
|
|
|
* @return Customer |
670
|
|
|
*/ |
671
|
|
|
public function setVat($vat) |
672
|
|
|
{ |
673
|
|
|
$this->vat = $vat; |
|
|
|
|
674
|
|
|
|
675
|
|
|
return $this; |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
/** |
679
|
|
|
* @return string |
680
|
|
|
*/ |
681
|
|
|
public function getVat() |
682
|
|
|
{ |
683
|
|
|
return $this->vat; |
684
|
|
|
} |
685
|
|
|
|
686
|
|
|
/** |
687
|
|
|
* @param bool $isActive |
688
|
|
|
* |
689
|
|
|
* @return Customer |
690
|
|
|
*/ |
691
|
|
|
public function setIsActive($isActive) |
692
|
|
|
{ |
693
|
|
|
$this->isActive = $isActive; |
694
|
|
|
|
695
|
|
|
return $this; |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
/** |
699
|
|
|
* @return bool |
700
|
|
|
*/ |
701
|
|
|
public function getIsActive() |
702
|
|
|
{ |
703
|
|
|
return $this->isActive; |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
/** |
707
|
|
|
* @param Collection $carts |
708
|
|
|
*/ |
709
|
|
|
public function setCarts($carts) |
710
|
|
|
{ |
711
|
|
|
$this->carts = $carts; |
712
|
|
|
} |
713
|
|
|
|
714
|
|
|
/** |
715
|
|
|
* @return Collection |
716
|
|
|
*/ |
717
|
|
|
public function getCarts() |
718
|
|
|
{ |
719
|
|
|
return $this->carts; |
720
|
|
|
} |
721
|
|
|
|
722
|
|
|
/** |
723
|
|
|
* @return Collection |
724
|
|
|
*/ |
725
|
|
|
public function getOrders() |
726
|
|
|
{ |
727
|
|
|
return $this->orders; |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
/** |
731
|
|
|
* @param int $originId |
732
|
|
|
* |
733
|
|
|
* @return Address|false |
734
|
|
|
*/ |
735
|
|
|
public function getAddressByOriginId($originId) |
736
|
|
|
{ |
737
|
|
|
return $this->addresses->filter( |
738
|
|
|
function (Address $item) use ($originId) { |
739
|
|
|
return $item->getOriginId() === $originId; |
740
|
|
|
} |
741
|
|
|
)->first(); |
742
|
|
|
} |
743
|
|
|
|
744
|
|
|
/** |
745
|
|
|
* @param double $lifetime |
746
|
|
|
* |
747
|
|
|
* @return Customer |
748
|
|
|
*/ |
749
|
|
|
public function setLifetime($lifetime) |
750
|
|
|
{ |
751
|
|
|
$this->lifetime = $lifetime; |
752
|
|
|
|
753
|
|
|
return $this; |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
/** |
757
|
|
|
* @return double |
758
|
|
|
*/ |
759
|
|
|
public function getLifetime() |
760
|
|
|
{ |
761
|
|
|
return $this->lifetime; |
762
|
|
|
} |
763
|
|
|
|
764
|
|
|
/** |
765
|
|
|
* @param string $currency |
766
|
|
|
* |
767
|
|
|
* @return Customer |
768
|
|
|
*/ |
769
|
|
|
public function setCurrency($currency) |
770
|
|
|
{ |
771
|
|
|
$this->currency = $currency; |
772
|
|
|
|
773
|
|
|
return $this; |
774
|
|
|
} |
775
|
|
|
|
776
|
|
|
/** |
777
|
|
|
* @return string |
778
|
|
|
*/ |
779
|
|
|
public function getCurrency() |
780
|
|
|
{ |
781
|
|
|
return $this->currency; |
782
|
|
|
} |
783
|
|
|
|
784
|
|
|
/** |
785
|
|
|
* Add address |
786
|
|
|
* |
787
|
|
|
* @param AbstractAddress $address |
788
|
|
|
* @return Customer |
789
|
|
|
*/ |
790
|
|
View Code Duplication |
public function addAddress(AbstractAddress $address) |
|
|
|
|
791
|
|
|
{ |
792
|
|
|
/** @var Address $address */ |
793
|
|
|
if (!$this->addresses->contains($address)) { |
794
|
|
|
$this->addresses->add($address); |
795
|
|
|
$address->setOwner($this); |
796
|
|
|
} |
797
|
|
|
|
798
|
|
|
return $this; |
799
|
|
|
} |
800
|
|
|
|
801
|
|
|
/** |
802
|
|
|
* @return User |
803
|
|
|
*/ |
804
|
|
|
public function getOwner() |
805
|
|
|
{ |
806
|
|
|
return $this->owner; |
807
|
|
|
} |
808
|
|
|
|
809
|
|
|
/** |
810
|
|
|
* @param User $user |
811
|
|
|
*/ |
812
|
|
|
public function setOwner(User $user) |
813
|
|
|
{ |
814
|
|
|
$this->owner = $user; |
815
|
|
|
} |
816
|
|
|
|
817
|
|
|
/** |
818
|
|
|
* Set organization |
819
|
|
|
* |
820
|
|
|
* @param Organization $organization |
821
|
|
|
* @return Customer |
822
|
|
|
*/ |
823
|
|
|
public function setOrganization(Organization $organization = null) |
824
|
|
|
{ |
825
|
|
|
$this->organization = $organization; |
826
|
|
|
|
827
|
|
|
return $this; |
828
|
|
|
} |
829
|
|
|
|
830
|
|
|
/** |
831
|
|
|
* Get organization |
832
|
|
|
* |
833
|
|
|
* @return Organization |
834
|
|
|
*/ |
835
|
|
|
public function getOrganization() |
836
|
|
|
{ |
837
|
|
|
return $this->organization; |
838
|
|
|
} |
839
|
|
|
|
840
|
|
|
/** |
841
|
|
|
* {@inheritdoc} |
842
|
|
|
*/ |
843
|
|
|
public function getSyncState() |
844
|
|
|
{ |
845
|
|
|
return $this->syncState; |
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
/** |
849
|
|
|
* {@inheritdoc} |
850
|
|
|
* |
851
|
|
|
* @return Customer |
852
|
|
|
*/ |
853
|
|
|
public function setSyncState($syncState) |
854
|
|
|
{ |
855
|
|
|
$this->syncState = $syncState; |
856
|
|
|
|
857
|
|
|
return $this; |
858
|
|
|
} |
859
|
|
|
|
860
|
|
|
/** |
861
|
|
|
* @return string |
862
|
|
|
*/ |
863
|
|
|
public function getPassword() |
864
|
|
|
{ |
865
|
|
|
return $this->password; |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
/** |
869
|
|
|
* @param string $password |
870
|
|
|
* @return Customer |
871
|
|
|
*/ |
872
|
|
|
public function setPassword($password) |
873
|
|
|
{ |
874
|
|
|
$this->password = $password; |
875
|
|
|
|
876
|
|
|
return $this; |
877
|
|
|
} |
878
|
|
|
|
879
|
|
|
/** |
880
|
|
|
* @param string $password |
881
|
|
|
* @return Customer |
882
|
|
|
*/ |
883
|
|
|
public function setGeneratedPassword($password) |
884
|
|
|
{ |
885
|
|
|
if ($password) { |
886
|
|
|
$this->setPassword($password); |
887
|
|
|
} |
888
|
|
|
|
889
|
|
|
return $this; |
890
|
|
|
} |
891
|
|
|
|
892
|
|
|
/** |
893
|
|
|
* @return string |
894
|
|
|
*/ |
895
|
|
|
public function getGeneratedPassword() |
896
|
|
|
{ |
897
|
|
|
return ''; |
898
|
|
|
} |
899
|
|
|
|
900
|
|
|
/** |
901
|
|
|
* @return NewsletterSubscriber[]|Collection |
902
|
|
|
*/ |
903
|
|
|
public function getNewsletterSubscribers() |
904
|
|
|
{ |
905
|
|
|
return $this->newsletterSubscribers; |
906
|
|
|
} |
907
|
|
|
|
908
|
|
|
/** |
909
|
|
|
* @param Collection|NewsletterSubscriber[] $newsletterSubscribers |
910
|
|
|
* @return Customer |
911
|
|
|
*/ |
912
|
|
|
public function setNewsletterSubscribers($newsletterSubscribers) |
913
|
|
|
{ |
914
|
|
|
$this->newsletterSubscribers = $newsletterSubscribers; |
915
|
|
|
|
916
|
|
|
return $this; |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
/** |
920
|
|
|
* @return bool |
921
|
|
|
*/ |
922
|
|
|
public function isSubscribed() |
923
|
|
|
{ |
924
|
|
|
foreach ($this->getNewsletterSubscribers() as $newsletterSubscriber) { |
925
|
|
|
if ($newsletterSubscriber->isSubscribed()) { |
926
|
|
|
return true; |
927
|
|
|
} |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
return false; |
931
|
|
|
} |
932
|
|
|
|
933
|
|
|
/** |
934
|
|
|
* @return \DateTime |
935
|
|
|
*/ |
936
|
|
|
public function getSyncedAt() |
937
|
|
|
{ |
938
|
|
|
return $this->syncedAt; |
939
|
|
|
} |
940
|
|
|
|
941
|
|
|
/** |
942
|
|
|
* @param \DateTime $syncedAt |
943
|
|
|
* @return Customer |
944
|
|
|
*/ |
945
|
|
|
public function setSyncedAt(\DateTime $syncedAt) |
946
|
|
|
{ |
947
|
|
|
$this->syncedAt = $syncedAt; |
948
|
|
|
|
949
|
|
|
return $this; |
950
|
|
|
} |
951
|
|
|
|
952
|
|
|
/** |
953
|
|
|
* @return \DateTime |
954
|
|
|
*/ |
955
|
|
|
public function getImportedAt() |
956
|
|
|
{ |
957
|
|
|
return $this->importedAt; |
958
|
|
|
} |
959
|
|
|
|
960
|
|
|
/** |
961
|
|
|
* @param \DateTime $importedAt |
962
|
|
|
* @return Customer |
963
|
|
|
*/ |
964
|
|
|
public function setImportedAt(\DateTime $importedAt) |
965
|
|
|
{ |
966
|
|
|
$this->importedAt = $importedAt; |
967
|
|
|
|
968
|
|
|
return $this; |
969
|
|
|
} |
970
|
|
|
|
971
|
|
|
/** |
972
|
|
|
* @return string |
973
|
|
|
*/ |
974
|
|
|
public function __toString() |
975
|
|
|
{ |
976
|
|
|
return (string)$this->getLastName() . (string)$this->getFirstName(); |
977
|
|
|
} |
978
|
|
|
} |
979
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.