From 226f4b9d72d0aa1184d9c12bec70a7f36f3cbf4a Mon Sep 17 00:00:00 2001 From: hbengamra Date: Sun, 2 Apr 2023 01:11:15 +0200 Subject: [PATCH] Task object instead of id as param Thanks to paramconverter we can get Task object directly instea of putting the ID and w can throw automaically an exception if it's not found --- form/form_collections.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/form/form_collections.rst b/form/form_collections.rst index 7922bc3f3a1..540f8d50377 100644 --- a/form/form_collections.rst +++ b/form/form_collections.rst @@ -598,12 +598,8 @@ the relationship between the removed ``Tag`` and ``Task`` object. class TaskController extends AbstractController { - public function edit($id, Request $request, EntityManagerInterface $entityManager): Response + public function edit(Task $task, Request $request, EntityManagerInterface $entityManager): Response { - if (null === $task = $entityManager->getRepository(Task::class)->find($id)) { - throw $this->createNotFoundException('No task found for id '.$id); - } - $originalTags = new ArrayCollection(); // Create an ArrayCollection of the current Tag objects in the database