Use [#MapEntity()] attribute to inject entity into method + for now set controller_resolver.auto_mapping to true

This commit is contained in:
2025-05-28 14:58:59 +02:00
parent f282ffbfd4
commit 8ec18a6fb8
24 changed files with 120 additions and 117 deletions

View File

@@ -24,6 +24,7 @@ use Chill\MainBundle\Security\Authorization\NotificationVoter;
use Chill\MainBundle\Security\ChillSecurity;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -99,7 +100,7 @@ class NotificationController extends AbstractController
}
#[Route(path: '/{id}/edit', name: 'chill_main_notification_edit')]
public function editAction(Notification $notification, Request $request): Response
public function editAction(#[MapEntity(id: 'id')] Notification $notification, Request $request): Response
{
$this->denyAccessUnlessGranted(NotificationVoter::NOTIFICATION_UPDATE, $notification);
@@ -127,7 +128,7 @@ class NotificationController extends AbstractController
}
#[Route(path: '/{id}/access_key', name: 'chill_main_notification_grant_access_by_access_key')]
public function getAccessByAccessKey(Notification $notification, Request $request): Response
public function getAccessByAccessKey(#[MapEntity(id: 'id')] Notification $notification, Request $request): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -215,7 +216,7 @@ class NotificationController extends AbstractController
}
#[Route(path: '/{id}/show', name: 'chill_main_notification_show')]
public function showAction(Notification $notification, Request $request): Response
public function showAction(#[MapEntity(id: 'id')] Notification $notification, Request $request): Response
{
$this->denyAccessUnlessGranted(NotificationVoter::NOTIFICATION_SEE, $notification);