8000 Task object instead of id as param · symfony/symfony-docs@4073ce5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4073ce5

Browse files
authored
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
1 parent 8497373 commit 4073ce5

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
@@ -643,12 +643,8 @@ the relationship between the removed ``Tag`` and ``Task`` object.
643643

644644
class TaskController extends AbstractController
645645
{
646-
public function edit($id, Request $request, EntityManagerInterface $entityManager): Response
646+
public function edit(Task $task, Request $request, EntityManagerInterface $entityManager): Response
647647
{
648-
if (null === $task = $entityManager->getRepository(Task::class)->find($id)) {
649-
throw $this->createNotFoundException('No task found for id '.$id);
650-
}
651-
652648
$originalTags = new ArrayCollection();
653649

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

0 commit comments

Comments
 (0)
0