<commit_before># FOSUser Bundle integration

This bundle is shipped with a bridge for the [FOSUserBundle](https://github.com/FriendsOfSymfony/FOSUserBundle). If the FOSUserBundle is enabled, this bridges registers to the persist, update and delete events to pass user objects to the UserManager, before redispatching the event. 

## Creating a `User` entity with serialization groups

Here's an example of declaration of a [doctrine ORM User class](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md#a-doctrine-orm-user-class). As shown you can use serialization groups to hide properties like `plainPassword` and `password` (only in read). The properties shown are handled with the [`normalizationContext`](serialization-groups-and-relations.md#normalization), while the properties you can modify are handled with [`DenormalizationContext`](serialization-groups-and-relations.md#denormalization).

First register the following service:

```yaml
# app/config/services.yml

resource.user:
        parent:    "api.resource"
        arguments: [ "AppBundle\Entity\User" ]
        calls:
            -      method:    "initNormalizationContext"
                   arguments: [ { groups: [ "user_read" ] } ]
            -      method:    "initDenormalizationContext"
                   arguments: [ { groups: [ "user_write" ] } ]
        tags:      [ { name: "api.resource" } ]
```

Then create your User entity with serialization groups:

```php
<?php<commit_msg>[Doc] minor changes in fosuser-bundle.md<commit_after># FOSUser Bundle integration

This bundle is shipped with a bridge for the [FOSUserBundle](https://github.com/FriendsOfSymfony/FOSUserBundle). If the FOSUserBundle is enabled, this bridges registers to the persist, update and delete events to pass user objects to the UserManager, before redispatching the event. 

## Creating a `User` entity with serialization groups

Here's an example of declaration of a [doctrine ORM User class](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md#a-doctrine-orm-user-class). As shown you can use serialization groups to hide properties like `plainPassword` (only in read) and `password`. The properties shown are handled with the [`normalizationContext`](serialization-groups-and-relations.md#normalization), while the properties you can modify are handled with [`denormalizationContext`](serialization-groups-and-relations.md#denormalization).

First register the following service:

```yaml
# app/config/services.yml

resource.user:
        parent:    "api.resource"
        arguments: [ "AppBundle\Entity\User" ]
        calls:
            -      method:    "initNormalizationContext"
                   arguments: [ { groups: [ "user_read" ] } ]
            -      method:    "initDenormalizationContext"
                   arguments: [ { groups: [ "user_write" ] } ]
        tags:      [ { name: "api.resource" } ]
```

Then create your User entity with serialization groups:

```php
<?php
{'fraction_non_alphanumeric': 0.09757716561566546, 'fraction_numerical': 0.0, 'mean_word_length': 3.6440677966101696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4529948', 'n_tokens_mistral': 822, 'n_tokens_neox': 795, 'n_words': 261}