UpdateUserController
extends AbstractController
in package
Updates a user from the mobile API.
Some sensitive attributes (id, roles, point of sale, dates, notification preferences) are deliberately ignored during deserialization; the password, if provided, is re-hashed separately.
Table of Contents
Properties
- $entityManager : EntityManagerInterface
- $passwordHasher : UserPasswordHasherInterface
- $serializer : SerializerInterface
- $validator : ValidatorInterface
Methods
- __construct() : mixed
- updateUser() : Response
- Applies the received changes to the target user.
Properties
$entityManager
private
EntityManagerInterface
$entityManager
$passwordHasher
private
UserPasswordHasherInterface
$passwordHasher
$serializer
private
SerializerInterface
$serializer
$validator
private
ValidatorInterface
$validator
Methods
__construct()
public
__construct(EntityManagerInterface $entityManager, SerializerInterface $serializer, ValidatorInterface $validator, UserPasswordHasherInterface $passwordHasher) : mixed
Parameters
- $entityManager : EntityManagerInterface
-
Doctrine entity manager.
- $serializer : SerializerInterface
-
Deserializes/serializes the user.
- $validator : ValidatorInterface
-
Validates the updated entity.
- $passwordHasher : UserPasswordHasherInterface
-
Hashes the optional new password.
updateUser()
Applies the received changes to the target user.
public
updateUser(Request $request, User $user) : Response
Parameters
- $request : Request
-
JSON request of the fields to modify (optionally "password").
- $user : User
-
User resolved by its identifier.
Attributes
- #[Route]
- "/api/point_of_sale/users/{id}"
- $name: 'update_user_api'
- $methods: ['PUT', 'PATCH']
Return values
Response —Serialized user (group "user:read"); 400 if the JSON body is invalid, the password empty or validation fails.