news item normalizer - to be generalized to dashboard item?

This commit is contained in:
Julie Lenaerts 2023-11-08 12:16:57 +01:00
parent 9591f1e49c
commit 9ec1376d29

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\DashboardItem;
use Chill\MainBundle\Entity\NewsItem;
use Chill\MainBundle\Repository\CenterRepository;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
@ -23,12 +24,12 @@ class NewsItemNormalizer implements NormalizerInterface
{
public function __construct(private readonly CenterRepository $repository) {}
public function normalize($newsItem, $format = null, array $context = [])
public function normalize($dashboardItem, $format = null, array $context = [])
{
/* @var NewsItem $newsItem */
/* @var DashboardItem $dashboardItem */
return [
'id' => $newsItem->getId(),
'type' => 'news',
'type' => $dashboardItem->getType(),
'metadata' => [
'title' => $newsItem->getTitle(),
'content' => $newsItem->getContent(),