Skip to content

Commit f140342

Browse files
committed
Minor refactor
1 parent 6f2c417 commit f140342

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

form/form_collections.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,12 @@ the relationship between the removed ``Tag`` and ``Task`` object.
655655
use Doctrine\Common\Collections\ArrayCollection;
656656

657657
// ...
658-
public function edit(Task $task, Request $request, EntityManagerInterface $entityManager)
658+
public function edit($id, Request $request, EntityManagerInterface $entityManager)
659659
{
660+
if (null === $task = $entityManager->getRepository(Task::class)->find($id)) {
661+
throw $this->createNotFoundException('No task found for id '.$id);
662+
}
663+
660664
$originalTags = new ArrayCollection();
661665

662666
// Create an ArrayCollection of the current Tag objects in the database
@@ -669,7 +673,6 @@ the relationship between the removed ``Tag`` and ``Task`` object.
669673
$editForm->handleRequest($request);
670674

671675
if ($editForm->isSubmitted() && $editForm->isValid()) {
672-
673676
// remove the relationship between the tag and the Task
674677
foreach ($originalTags as $tag) {
675678
if (false === $task->getTags()->contains($tag)) {

0 commit comments

Comments
 (0)