mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
fix serialization - deserialization
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user