@@ -48,8 +48,9 @@ Or if you prefer XML:
48
48
The simplest way to create a Group class is to extend the mapped superclass
49
49
provided by the bundle.
50
50
51
- ** a) ORM Group class implementation**
51
+ #### a) ORM Group class implementation
52
52
53
+ ##### Annotations
53
54
``` php
54
55
// src/MyProject/MyBundle/Entity/Group.php
55
56
<?php
@@ -76,7 +77,47 @@ class Group extends BaseGroup
76
77
77
78
** Note:** ` Group ` is a reserved keyword in SQL so it cannot be used as the table name.
78
79
79
- ** b) MongoDB Group class implementation**
80
+ ##### yaml
81
+
82
+
83
+ ``` php
84
+ <?php
85
+ // src/Acme/UserBundle/Entity/Group.php
86
+
87
+ namespace Acme\UserBundle\Entity;
88
+
89
+ use FOS\UserBundle\Entity\Group as BaseGroup;
90
+
91
+ /**
92
+ * Group
93
+ */
94
+ class Group extends BaseGroup
95
+ {
96
+ /**
97
+ * @var integer
98
+ */
99
+ protected $id;
100
+
101
+ public function __construct()
102
+ {
103
+ parent::__construct();
104
+ // your own logic
105
+ }
106
+ }
107
+ ```
108
+ ``` yaml
109
+ # src/Acme/UserBundle/Resources/config/doctrine/Group.orm.yml
110
+ Acme\UserBundle\Entity\Group :
111
+ type : entity
112
+ table : fos_group
113
+ id :
114
+ id :
115
+ type : integer
116
+ generator :
117
+ strategy : AUTO
118
+ ` ` `
119
+
120
+ #### b) MongoDB Group class implementation
80
121
81
122
` ` ` php
82
123
// src/MyProject/MyBundle/Document/Group.php
@@ -99,7 +140,7 @@ class Group extends BaseGroup
99
140
}
100
141
```
101
142
102
- ** c) CouchDB Group class implementation**
143
+ #### c) CouchDB Group class implementation
103
144
104
145
``` php
105
146
// src/MyProject/MyBundle/Document/Group.php
@@ -126,8 +167,9 @@ class Group extends BaseGroup
126
167
127
168
The next step is to map the relation in your ` User ` class.
128
169
129
- ** a) ORM User-Group mapping**
170
+ #### a) ORM User-Group mapping
130
171
172
+ ##### Annotations
131
173
``` php
132
174
// src/MyProject/MyBundle/Entity/User.php
133
175
<?php
@@ -161,7 +203,62 @@ class User extends BaseUser
161
203
}
162
204
```
163
205
164
- ** b) MongoDB User-Group mapping**
206
+ ##### yaml
207
+ ``` php
208
+ <?php
209
+ // src/Acme/UserBundle/Entity/User.php
210
+
211
+ namespace Acme\UserBundle\Entity;
212
+
213
+ use FOS\UserBundle\Entity\User as BaseUser;
214
+
215
+ /**
216
+ * User
217
+ */
218
+ class User extends BaseUser
219
+ {
220
+ /**
221
+ * @var integer
222
+ */
223
+ protected $id;
224
+
225
+ /**
226
+ * @var \Doctrine\Common\Collections\Collection
227
+ */
228
+ protected $groups;
229
+
230
+ public function __construct()
231
+ {
232
+ parent::__construct();
233
+ $this->groups = new \Doctrine\Common\Collections\ArrayCollection();
234
+ // your own logic
235
+ }
236
+ }
237
+ ```
238
+ ``` yaml
239
+ # src/Acme/UserBundle/Resources/config/doctrine/User.orm.yml
240
+ Acme\UserBundle\Entity\User :
241
+ type : entity
242
+ table : fos_user
243
+ id :
244
+ id :
245
+ type : integer
246
+ generator :
247
+ strategy : AUTO
248
+ manyToMany :
249
+ groups :
250
+ targetEntity : Group
251
+ joinTable :
252
+ name : fos_user_group
253
+ joinColumns :
254
+ user_id :
255
+ referencedColumnName : id
256
+ inverseJoinColumns :
257
+ group_id :
258
+ referencedColumnName : id
259
+ ` ` `
260
+
261
+ #### b) MongoDB User-Group mapping
165
262
166
263
` ` ` php
167
264
// src/MyProject/MyBundle/Document/User.php
@@ -187,7 +284,7 @@ class User extends BaseUser
187
284
}
188
285
```
189
286
190
- ** c) CouchDB User-Group mapping**
287
+ #### c) CouchDB User-Group mapping
191
288
192
289
``` php
193
290
// src/MyProject/MyBundle/Document/User.php
0 commit comments