diff --git a/api/src/Entity/Book.php b/api/src/Entity/Book.php index 25dee0858..734f58e71 100644 --- a/api/src/Entity/Book.php +++ b/api/src/Entity/Book.php @@ -24,6 +24,8 @@ use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Uid\Uuid; use Symfony\Component\Validator\Constraints as Assert; @@ -61,11 +63,11 @@ ), ], normalizationContext: [ - 'groups' => ['Book:read:admin', 'Enum:read'], - 'skip_null_values' => true, + AbstractNormalizer::GROUPS => ['Book:read:admin', 'Enum:read'], + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, ], denormalizationContext: [ - 'groups' => ['Book:write'], + AbstractNormalizer::GROUPS => ['Book:write'], ], // todo waiting for https://github.com/api-platform/core/pull/5844 // collectDenormalizationErrors: true, @@ -80,8 +82,8 @@ new Get(), ], normalizationContext: [ - 'groups' => ['Book:read', 'Enum:read'], - 'skip_null_values' => true, + AbstractNormalizer::GROUPS => ['Book:read', 'Enum:read'], + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, ] )] #[ORM\Entity(repositoryClass: BookRepository::class)] diff --git a/api/src/Entity/Bookmark.php b/api/src/Entity/Bookmark.php index 14bc11c61..b769e7f68 100644 --- a/api/src/Entity/Bookmark.php +++ b/api/src/Entity/Bookmark.php @@ -19,6 +19,8 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Uid\Uuid; use Symfony\Component\Validator\Constraints as Assert; @@ -40,14 +42,14 @@ ), ], normalizationContext: [ - 'groups' => ['Bookmark:read'], - 'skip_null_values' => true, + AbstractNormalizer::GROUPS => ['Bookmark:read'], + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, IriTransformerNormalizer::CONTEXT_KEY => [ 'book' => '/books/{id}{._format}', ], ], denormalizationContext: [ - 'groups' => ['Bookmark:write'], + AbstractNormalizer::GROUPS => ['Bookmark:write'], ], // todo waiting for https://github.com/api-platform/core/pull/5844 // collectDenormalizationErrors: true, diff --git a/api/src/Entity/Review.php b/api/src/Entity/Review.php index 1c78b3aab..229115776 100644 --- a/api/src/Entity/Review.php +++ b/api/src/Entity/Review.php @@ -24,6 +24,8 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Uid\Uuid; use Symfony\Component\Validator\Constraints as Assert; @@ -66,11 +68,11 @@ 'book' => '/admin/books/{id}{._format}', 'user' => '/admin/users/{id}{._format}', ], - 'skip_null_values' => true, - 'groups' => ['Review:read', 'Review:read:admin'], + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + AbstractNormalizer::GROUPS => ['Review:read', 'Review:read:admin'], ], denormalizationContext: [ - 'groups' => ['Review:write', 'Review:write:admin'], + AbstractNormalizer::GROUPS => ['Review:write', 'Review:write:admin'], ], // todo waiting for https://github.com/api-platform/core/pull/5844 // collectDenormalizationErrors: true, @@ -101,7 +103,7 @@ processor: ReviewPersistProcessor::class, provider: CreateProvider::class, itemUriTemplate: '/books/{bookId}/reviews/{id}{._format}', - validationContext: ['groups' => ['Default', 'Review:create']] + validationContext: [AbstractNormalizer::GROUPS => ['Default', 'Review:create']] ), new Patch( uriTemplate: '/books/{bookId}/reviews/{id}{._format}', @@ -129,11 +131,11 @@ 'book' => '/books/{id}{._format}', 'user' => '/users/{id}{._format}', ], - 'skip_null_values' => true, - 'groups' => ['Review:read'], + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + AbstractNormalizer::GROUPS => ['Review:read'], ], denormalizationContext: [ - 'groups' => ['Review:write'], + AbstractNormalizer::GROUPS => ['Review:write'], ], // todo waiting for https://github.com/api-platform/core/pull/5844 // collectDenormalizationErrors: true diff --git a/api/src/Entity/User.php b/api/src/Entity/User.php index bc84bf169..237b01520 100644 --- a/api/src/Entity/User.php +++ b/api/src/Entity/User.php @@ -14,6 +14,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Uid\Uuid; /** @@ -41,8 +43,8 @@ ), ], normalizationContext: [ - 'groups' => ['User:read'], - 'skip_null_values' => true, + AbstractNormalizer::GROUPS => ['User:read'], + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, ] )] #[ORM\Entity(repositoryClass: UserRepository::class)]