mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix serialization - deserialization
This commit is contained in:
parent
c56a125a78
commit
c629dd79cb
@ -27,7 +27,7 @@ class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, Denorma
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function denormalize($data, string $type, ?string $format = null, array $context = [])
|
||||
public function denormalize($data, string $type, ?string $format = null, array $context = []): PrivateCommentEmbeddable
|
||||
{
|
||||
if (null === $data) {
|
||||
return null;
|
||||
@ -35,22 +35,24 @@ class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, Denorma
|
||||
|
||||
$comment = new PrivateCommentEmbeddable();
|
||||
|
||||
$comment->setCommentForUser($this->security->getUser(), $data['privateComment']);
|
||||
$comment->setCommentForUser($this->security->getUser(), $data);
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
||||
public function supportsDenormalization($data, string $type, ?string $format = null)
|
||||
public function supportsDenormalization($data, string $type, ?string $format = null): bool
|
||||
{
|
||||
return $type === CommentEmbeddable::class;
|
||||
return $type === PrivateCommentEmbeddable::class;
|
||||
}
|
||||
|
||||
public function normalize($comment, $format = null, array $contect = [])
|
||||
public function normalize($comment, $format = null, array $contect = []): string
|
||||
{
|
||||
return $comment->getComment();
|
||||
return $comment->getCommentForUser($this->security->getUser());
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, ?string $format = null)
|
||||
public function supportsNormalization($data, ?string $format = null): bool
|
||||
{
|
||||
return $data instanceof CommentEmbeddable;
|
||||
return $data instanceof PrivateCommentEmbeddable;
|
||||
}
|
||||
|
||||
}
|
@ -13,4 +13,6 @@ services:
|
||||
Chill\MainBundle\Serializer\Normalizer\PrivateCommentEmbeddableNormalizer:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: 'serializer.normalizer', priority: 64 }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user