@@ -284,28 +284,23 @@ You now can run the following command to create the model:
284
284
namespace Acme\ApiBundle\Document;
285
285
286
286
use FOS\OAuthServerBundle\Document\Client as BaseClient;
287
+ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
287
288
289
+ /**
290
+ * @ODM\Document
291
+ */
288
292
class Client extends BaseClient
289
293
{
294
+
295
+ /**
296
+ * @ODM\Id
297
+ *
298
+ * @var string|null
299
+ */
290
300
protected $id;
291
301
}
292
302
```
293
303
294
- ``` xml
295
- <!-- src/Acme/ApiBundle/Resources/config/doctrine/Client.mongodb.xml -->
296
-
297
- <doctrine-mongo-mapping xmlns =" http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
298
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
299
- xsi : schemaLocation =" http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
300
- http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd" >
301
-
302
- <document name =" Acme\ApiBundle\Document\Client" db =" acme" collection =" oauthClient" customId =" true" >
303
- <field fieldName =" id" id =" true" strategy =" AUTO" />
304
- </document >
305
-
306
- </doctrine-mongo-mapping >
307
- ```
308
-
309
304
``` php
310
305
<?php
311
306
@@ -315,40 +310,36 @@ namespace Acme\ApiBundle\Document;
315
310
316
311
use FOS\OAuthServerBundle\Document\AuthCode as BaseAuthCode;
317
312
use FOS\OAuthServerBundle\Model\ClientInterface;
313
+ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
318
314
315
+ /**
316
+ * @ODM\Document
317
+ */
319
318
class AuthCode extends BaseAuthCode
320
319
{
320
+ /**
321
+ * @ODM\Id
322
+ *
323
+ * @var string|null
324
+ */
321
325
protected $id;
322
- protected $client;
323
326
324
- public function getClient()
325
- {
326
- return $this->client;
327
- }
327
+ /**
328
+ * @var ClientInterface|null
329
+ *
330
+ * @ODM\ReferenceOne(targetDocument=Client::class)
331
+ */
332
+ protected $client;
328
333
329
- public function setClient(ClientInterface $client)
330
- {
331
- $this->client = $client;
332
- }
334
+ /**
335
+ * @var Your\Own\Entity\User|null
336
+ *
337
+ * @ODM\ReferenceOne(targetDocument=Your\Own\Entity\User::class)
338
+ */
339
+ protected $user;
333
340
}
334
341
```
335
342
336
- ``` xml
337
- <!-- src/Acme/ApiBundle/Resources/config/doctrine/AuthCode.mongodb.xml -->
338
-
339
- <doctrine-mongo-mapping xmlns =" http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
340
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
341
- xsi : schemaLocation =" http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
342
- http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd" >
343
-
344
- <document name =" Acme\ApiBundle\Document\AuthCode" db =" acme" collection =" oauthAuthCode" customId =" true" >
345
- <field fieldName =" id" id =" true" strategy =" AUTO" />
346
- <reference-one target-document =" Acme\ApiBundle\Document\Client" field =" client" />
347
- </document >
348
-
349
- </doctrine-mongo-mapping >
350
- ```
351
-
352
343
``` php
353
344
<?php
354
345
@@ -358,40 +349,36 @@ namespace Acme\ApiBundle\Document;
358
349
359
350
use FOS\OAuthServerBundle\Document\AccessToken as BaseAccessToken;
360
351
use FOS\OAuthServerBundle\Model\ClientInterface;
352
+ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
361
353
354
+ /**
355
+ * @ODM\Document
356
+ */
362
357
class AccessToken extends BaseAccessToken
363
358
{
359
+ /**
360
+ * @ODM\Id
361
+ *
362
+ * @var string|null
363
+ */
364
364
protected $id;
365
- protected $client;
366
365
367
- public function getClient()
368
- {
369
- return $this->client;
370
- }
366
+ /**
367
+ * @var ClientInterface|null
368
+ *
369
+ * @ODM\ReferenceOne(targetDocument=Client::class)
370
+ */
371
+ protected $client;
371
372
372
- public function setClient(ClientInterface $client)
373
- {
374
- $this->client = $client;
375
- }
373
+ /**
374
+ * @var Your\Own\Entity\User|null
375
+ *
376
+ * @ODM\ReferenceOne(targetDocument=Your\Own\Entity\User::class)
377
+ */
378
+ protected $user;
376
379
}
377
380
```
378
381
379
- ``` xml
380
- <!-- src/Acme/ApiBundle/Resources/config/doctrine/AccessToken.mongodb.xml -->
381
-
382
- <doctrine-mongo-mapping xmlns =" http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
383
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
384
- xsi : schemaLocation =" http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
385
- http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd" >
386
-
387
- <document name =" Acme\ApiBundle\Document\AccessToken" db =" acme" collection =" oauthAccessToken" customId =" true" >
388
- <field fieldName =" id" id =" true" strategy =" AUTO" />
389
- <reference-one target-document =" Acme\ApiBundle\Document\Client" field =" client" />
390
- </document >
391
-
392
- </doctrine-mongo-mapping >
393
- ```
394
-
395
382
``` php
396
383
<?php
397
384
@@ -401,40 +388,36 @@ namespace Acme\ApiBundle\Document;
401
388
402
389
use FOS\OAuthServerBundle\Document\RefreshToken as BaseRefreshToken;
403
390
use FOS\OAuthServerBundle\Model\ClientInterface;
391
+ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
404
392
393
+ /**
394
+ * @ODM\Document
395
+ */
405
396
class RefreshToken extends BaseRefreshToken
406
397
{
398
+ /**
399
+ * @ODM\Id
400
+ *
401
+ * @var string|null
402
+ */
407
403
protected $id;
408
- protected $client;
409
404
410
- public function getClient()
411
- {
412
- return $this->client;
413
- }
405
+ /**
406
+ * @var ClientInterface|null
407
+ *
408
+ * @ODM\ReferenceOne(targetDocument=Client::class)
409
+ */
410
+ protected $client;
414
411
415
- public function setClient(ClientInterface $client)
416
- {
417
- $this->client = $client;
418
- }
412
+ /**
413
+ * @var Your\Own\Entity\User|null
414
+ *
415
+ * @ODM\ReferenceOne(targetDocument=Your\Own\Entity\User::class)
416
+ */
417
+ protected $user;
419
418
}
420
419
```
421
420
422
- ``` xml
423
- <!-- src/Acme/ApiBundle/Resources/config/doctrine/RefreshToken.mongodb.xml -->
424
-
425
- <doctrine-mongo-mapping xmlns =" http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
426
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
427
- xsi : schemaLocation =" http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
428
- http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd" >
429
-
430
- <document name =" Acme\ApiBundle\Document\RefreshToken" db =" acme" collection =" oauthRefreshToken" customId =" true" >
431
- <field fieldName =" id" id =" true" strategy =" AUTO" />
432
- <reference-one target-document =" Acme\ApiBundle\Document\Client" field =" client" />
433
- </document >
434
-
435
- </doctrine-mongo-mapping >
436
- ```
437
-
438
421
### Step 4: Configure your application's security.yml
439
422
440
423
In order for Symfony's security component to use the FOSOAuthServerBundle, you must
0 commit comments