mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
AccompanyingPeriodResource: fix deserialization + code style
This commit is contained in:
@@ -38,15 +38,6 @@ class AccompanyingPeriodResourceNormalizer implements DenormalizerAwareInterface
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function normalize($resource, $format = null, array $context = [])
|
||||
{
|
||||
return [
|
||||
'type' => 'accompanying_period_resource',
|
||||
'id' => $resource->getId(),
|
||||
'comment' => $resource->getComment()
|
||||
];
|
||||
}
|
||||
|
||||
public function denormalize($data, $type, $format = null, array $context = [])
|
||||
{
|
||||
$resource = $this->extractObjectToPopulate($type, $context);
|
||||
@@ -93,9 +84,22 @@ class AccompanyingPeriodResourceNormalizer implements DenormalizerAwareInterface
|
||||
$resource->setResource($res);
|
||||
}
|
||||
|
||||
if (array_key_exists('comment', $data)) {
|
||||
$resource->setComment($data['comment']);
|
||||
}
|
||||
|
||||
return $resource;
|
||||
}
|
||||
|
||||
public function normalize($resource, $format = null, array $context = [])
|
||||
{
|
||||
return [
|
||||
'type' => 'accompanying_period_resource',
|
||||
'id' => $resource->getId(),
|
||||
'comment' => $resource->getComment(),
|
||||
];
|
||||
}
|
||||
|
||||
public function supportsDenormalization($data, $type, $format = null)
|
||||
{
|
||||
return Resource::class === $type;
|
||||
|
Reference in New Issue
Block a user