Skip to content

Commit 14ee636

Browse files
committed
minor #18156 Task object instead of id as param (hbgamra)
This PR was submitted for the 6.3 branch but it was merged into the 5.4 branch instead. Discussion ---------- Task object instead of id as param Thanks to Paramconverter we can get Task object directly instead of putting the $id and we can throw automatically an exception if the task was not found <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- 226f4b9 Task object instead of id as param
2 parents 56f05a8 + 226f4b9 commit 14ee636

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

form/form_collections.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,8 @@ the relationship between the removed ``Tag`` and ``Task`` object.
598598

599599
class TaskController extends AbstractController
600600
{
601-
public function edit($id, Request $request, EntityManagerInterface $entityManager): Response
601+
public function edit(Task $task, Request $request, EntityManagerInterface $entityManager): Response
602602
{
603-
if (null === $task = $entityManager->getRepository(Task::class)->find($id)) {
604-
throw $this->createNotFoundException('No task found for id '.$id);
605-
}
606-
607603
$originalTags = new ArrayCollection();
608604

609605
// Create an ArrayCollection of the current Tag objects in the database

0 commit comments

Comments
 (0)