16
16
use Oro \Bundle \DataAuditBundle \Metadata \Annotation as Oro ;
17
17
18
18
use Oro \Bundle \EntityConfigBundle \Metadata \Annotation \Config ;
19
+ use Oro \Bundle \EntityConfigBundle \Metadata \Annotation \ConfigField ;
19
20
20
21
use Oro \Bundle \UserBundle \Entity \User ;
21
22
28
29
* routeName="orocrm_account_index",
29
30
* routeView="orocrm_account_view",
30
31
* defaultValues={
31
- * "entity"={"label"="Account", "plural_label"="Accounts"},
32
+ * "entity"={
33
+ * "label"="Account",
34
+ * "plural_label"="Accounts",
35
+ * "icon"="icon-suitcase"
36
+ * },
32
37
* "ownership"={
33
38
* "owner_type"="USER",
34
39
* "owner_field_name"="owner",
37
42
* "security"={
38
43
* "type"="ACL",
39
44
* "group_name"=""
45
+ * },
46
+ * "merge"={
47
+ * "enable"=true
40
48
* }
41
49
* }
42
50
* )
@@ -57,6 +65,7 @@ class Account extends ExtendAccount implements Taggable
57
65
* @ORM\Column(type="string", length=255)
58
66
* @Soap\ComplexType("string")
59
67
* @Oro\Versioned
68
+ * @ConfigField(defaultValues={"merge"={"enable"=true}})
60
69
*/
61
70
protected $ name ;
62
71
@@ -65,6 +74,7 @@ class Account extends ExtendAccount implements Taggable
65
74
* @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User")
66
75
* @ORM\JoinColumn(name="user_owner_id", referencedColumnName="id", onDelete="SET NULL")
67
76
* @Soap\ComplexType("string", nillable=true)
77
+ * @ConfigField(defaultValues={"merge"={"enable"=true}})
68
78
*/
69
79
protected $ owner ;
70
80
@@ -73,6 +83,7 @@ class Account extends ExtendAccount implements Taggable
73
83
*
74
84
* @ORM\ManyToOne(targetEntity="Oro\Bundle\AddressBundle\Entity\Address", cascade={"persist", "remove"})
75
85
* @ORM\JoinColumn(name="shipping_address_id", referencedColumnName="id", onDelete="SET NULL")
86
+ * @ConfigField(defaultValues={"merge"={"enable"=true}})
76
87
*/
77
88
protected $ shippingAddress ;
78
89
@@ -81,6 +92,8 @@ class Account extends ExtendAccount implements Taggable
81
92
*
82
93
* @ORM\ManyToOne(targetEntity="Oro\Bundle\AddressBundle\Entity\Address", cascade={"persist", "remove"})
83
94
* @ORM\JoinColumn(name="billing_address_id", referencedColumnName="id", onDelete="SET NULL")
95
+ * @ConfigField(defaultValues={"merge"={"enable"=true}})
96
+ * @ConfigField(defaultValues={"merge"={"enable"=true}})
84
97
*/
85
98
protected $ billingAddress ;
86
99
@@ -91,6 +104,7 @@ class Account extends ExtendAccount implements Taggable
91
104
*
92
105
* @ORM\ManyToMany(targetEntity="OroCRM\Bundle\ContactBundle\Entity\Contact", inversedBy="accounts")
93
106
* @ORM\JoinTable(name="orocrm_account_to_contact")
107
+ * @ConfigField(defaultValues={"merge"={"enable"=true}})
94
108
*/
95
109
protected $ contacts ;
96
110
@@ -101,6 +115,7 @@ class Account extends ExtendAccount implements Taggable
101
115
*
102
116
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\ContactBundle\Entity\Contact")
103
117
* @ORM\JoinColumn(name="default_contact_id", referencedColumnName="id", onDelete="SET NULL")
118
+ * @ConfigField(defaultValues={"merge"={"enable"=true}})
104
119
*/
105
120
protected $ defaultContact ;
106
121
@@ -122,6 +137,7 @@ class Account extends ExtendAccount implements Taggable
122
137
123
138
/**
124
139
* @var ArrayCollection $tags
140
+ * @ConfigField(defaultValues={"merge"={"enable"=true}})
125
141
*/
126
142
protected $ tags ;
127
143
@@ -240,6 +256,19 @@ public function addContact(Contact $contact)
240
256
return $ this ;
241
257
}
242
258
259
+ /**
260
+ * Set contacts collection
261
+ *
262
+ * @param Collection $contacts
263
+ * @return Account
264
+ */
265
+ public function setContacts (Collection $ contacts )
266
+ {
267
+ $ this ->contacts = $ contacts ;
268
+
269
+ return $ this ;
270
+ }
271
+
243
272
/**
244
273
* Get shipping address
245
274
*
@@ -256,7 +285,7 @@ public function getShippingAddress()
256
285
* @param Address $address
257
286
* @return Account
258
287
*/
259
- public function setShippingAddress (Address $ address )
288
+ public function setShippingAddress ($ address )
260
289
{
261
290
$ this ->shippingAddress = $ address ;
262
291
@@ -279,7 +308,7 @@ public function getBillingAddress()
279
308
* @param Address $address
280
309
* @return Account
281
310
*/
282
- public function setBillingAddress (Address $ address )
311
+ public function setBillingAddress ($ address )
283
312
{
284
313
$ this ->billingAddress = $ address ;
285
314
@@ -383,6 +412,10 @@ public function setDefaultContact($defaultContact)
383
412
{
384
413
$ this ->defaultContact = $ defaultContact ;
385
414
415
+ if ($ defaultContact && !$ this ->contacts ->contains ($ defaultContact )) {
416
+ $ this ->addContact ($ defaultContact );
417
+ }
418
+
386
419
return $ this ;
387
420
}
388
421
0 commit comments