mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-02-28 11:09:41 +00:00
Use [#MapEntity()] attribute to inject entity into method + for now set controller_resolver.auto_mapping to true
This commit is contained in:
@@ -19,6 +19,7 @@ use Chill\MainBundle\Security\Authorization\NotificationVoter;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\MainBundle\Serializer\Model\Counter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
@@ -32,13 +33,13 @@ class NotificationApiController
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly NotificationRepository $notificationRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) {}
|
||||
|
||||
#[Route(path: '/{id}/mark/read', name: 'chill_api_main_notification_mark_read', methods: ['POST'])]
|
||||
public function markAsRead(Notification $notification): JsonResponse
|
||||
public function markAsRead(#[MapEntity(id: 'id')] Notification $notification): JsonResponse
|
||||
{
|
||||
return $this->markAs('read', $notification);
|
||||
}
|
||||
|
||||
#[Route(path: '/{id}/mark/unread', name: 'chill_api_main_notification_mark_unread', methods: ['POST'])]
|
||||
public function markAsUnread(Notification $notification): JsonResponse
|
||||
public function markAsUnread(#[MapEntity(id: 'id')] Notification $notification): JsonResponse
|
||||
{
|
||||
return $this->markAs('unread', $notification);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user