Skip to content

Commit 869f05a

Browse files
committed
Improve setup docs regarding Doctrine ODM
1 parent 504530d commit 869f05a

File tree

1 file changed

+73
-90
lines changed

1 file changed

+73
-90
lines changed

Resources/doc/index.md

Lines changed: 73 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -284,28 +284,23 @@ You now can run the following command to create the model:
284284
namespace Acme\ApiBundle\Document;
285285

286286
use FOS\OAuthServerBundle\Document\Client as BaseClient;
287+
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
287288

289+
/**
290+
* @ODM\Document
291+
*/
288292
class Client extends BaseClient
289293
{
294+
295+
/**
296+
* @ODM\Id
297+
*
298+
* @var string|null
299+
*/
290300
protected $id;
291301
}
292302
```
293303

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-
309304
``` php
310305
<?php
311306

@@ -315,40 +310,36 @@ namespace Acme\ApiBundle\Document;
315310

316311
use FOS\OAuthServerBundle\Document\AuthCode as BaseAuthCode;
317312
use FOS\OAuthServerBundle\Model\ClientInterface;
313+
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
318314

315+
/**
316+
* @ODM\Document
317+
*/
319318
class AuthCode extends BaseAuthCode
320319
{
320+
/**
321+
* @ODM\Id
322+
*
323+
* @var string|null
324+
*/
321325
protected $id;
322-
protected $client;
323326

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;
328333

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;
333340
}
334341
```
335342

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-
352343
``` php
353344
<?php
354345

@@ -358,40 +349,36 @@ namespace Acme\ApiBundle\Document;
358349

359350
use FOS\OAuthServerBundle\Document\AccessToken as BaseAccessToken;
360351
use FOS\OAuthServerBundle\Model\ClientInterface;
352+
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
361353

354+
/**
355+
* @ODM\Document
356+
*/
362357
class AccessToken extends BaseAccessToken
363358
{
359+
/**
360+
* @ODM\Id
361+
*
362+
* @var string|null
363+
*/
364364
protected $id;
365-
protected $client;
366365

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;
371372

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;
376379
}
377380
```
378381

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-
395382
``` php
396383
<?php
397384

@@ -401,40 +388,36 @@ namespace Acme\ApiBundle\Document;
401388

402389
use FOS\OAuthServerBundle\Document\RefreshToken as BaseRefreshToken;
403390
use FOS\OAuthServerBundle\Model\ClientInterface;
391+
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
404392

393+
/**
394+
* @ODM\Document
395+
*/
405396
class RefreshToken extends BaseRefreshToken
406397
{
398+
/**
399+
* @ODM\Id
400+
*
401+
* @var string|null
402+
*/
407403
protected $id;
408-
protected $client;
409404

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;
414411

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;
419418
}
420419
```
421420

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-
438421
### Step 4: Configure your application's security.yml
439422

440423
In order for Symfony's security component to use the FOSOAuthServerBundle, you must

0 commit comments

Comments
 (0)