From e1d782c8a0371ffe3e5d066b8c6d048dffed8ed2 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Thu, 30 May 2024 11:43:48 +0200 Subject: [PATCH] refs #379. Allow_extra_attributes false --- config/api_platform/User.yaml | 1 + config/packages/api_platform.yaml | 2 ++ src/State/Processor/UserProcessor.php | 6 +++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config/api_platform/User.yaml b/config/api_platform/User.yaml index 427c416..d82f4c2 100644 --- a/config/api_platform/User.yaml +++ b/config/api_platform/User.yaml @@ -7,6 +7,7 @@ resources: groups: ['default', 'user:read'] denormalization_context: groups: ['user:write'] + operations: ApiPlatform\Metadata\GetCollection: provider: App\State\Provider\UserProvider diff --git a/config/packages/api_platform.yaml b/config/packages/api_platform.yaml index 8fad293..ee2c7ec 100644 --- a/config/packages/api_platform.yaml +++ b/config/packages/api_platform.yaml @@ -11,6 +11,8 @@ api_platform: paths: ['%kernel.project_dir%/config/api_platform', '%kernel.project_dir%/src/Dto'] defaults: pagination_client_items_per_page: true + denormalization_context: + allow_extra_attributes: false cache_headers: vary: [ 'Content-Type', 'Authorization', 'Origin' ] extra_properties: diff --git a/src/State/Processor/UserProcessor.php b/src/State/Processor/UserProcessor.php index fec80b5..bf8558b 100644 --- a/src/State/Processor/UserProcessor.php +++ b/src/State/Processor/UserProcessor.php @@ -48,12 +48,12 @@ class UserProcessor implements ProcessorInterface throw new \Exception(sprintf('data is not instance of %s', UserInput::class)); } - $entity = null; + $user = null; if (isset($uriVariables['uuid'])) { - $entity = $this->userRepository->findOneByUuid($uriVariables['uuid']); + $user = $this->userRepository->findOneByUuid($uriVariables['uuid']); } - $user = $data->createOrUpdateEntity($entity); + $user = $data->createOrUpdateEntity($user); if ($data->password !== null){ $user->setPassword($this->userPasswordHasher->hashPassword($user, $data->password));