mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 00:24:59 +00:00
remove custom serializer and adjust annotations of news item entity
This commit is contained in:
@@ -44,7 +44,7 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
/**
|
/**
|
||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
*
|
*
|
||||||
* @Groups({"read", "write"})
|
* @Groups({"read"})
|
||||||
*
|
*
|
||||||
* @Assert\NotBlank
|
* @Assert\NotBlank
|
||||||
*
|
*
|
||||||
@@ -55,7 +55,7 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
/**
|
/**
|
||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
*
|
*
|
||||||
* @Groups({"read", "write"})
|
* @Groups({"read"})
|
||||||
*
|
*
|
||||||
* @Assert\NotBlank
|
* @Assert\NotBlank
|
||||||
*
|
*
|
||||||
|
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\NewsItem;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
||||||
|
|
||||||
class NewsItemNormalizer implements NormalizerInterface
|
|
||||||
{
|
|
||||||
public function normalize($newsItem, $format = null, array $context = [])
|
|
||||||
{
|
|
||||||
/* @var NewsItem $newsItem */
|
|
||||||
return [
|
|
||||||
'id' => $newsItem->getId(),
|
|
||||||
'title' => $newsItem->getTitle(),
|
|
||||||
'content' => $newsItem->getContent(),
|
|
||||||
'startdate' => $newsItem->getStartDate(),
|
|
||||||
'enddate' => $newsItem->getEndDate(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsNormalization($data, $format = null): bool
|
|
||||||
{
|
|
||||||
return $data instanceof NewsItem && 'json' === $format;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user