Skip to content

Commit 2154535

Browse files
javiereguiluzGuikingone
authored andcommitted
Minor refactor
1 parent 56e964a commit 2154535

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
@@ -687,8 +687,12 @@ the relationship between the removed ``Tag`` and ``Task`` object.
687687
use Doctrine\Common\Collections\ArrayCollection;
688688

689689
// ...
690-
public function edit(Task $task, Request $request, EntityManagerInterface $entityManager)
690+
public function edit($id, Request $request, EntityManagerInterface $entityManager)
691691
{
692+
if (null === $task = $entityManager->getRepository(Task::class)->find($id)) {
693+
throw $this->createNotFoundException('No task found for id '.$id);
694+
}
695+
692696
$originalTags = new ArrayCollection();
693697

694698
// Create an ArrayCollection of the current Tag objects in the database
@@ -701,7 +705,6 @@ the relationship between the removed ``Tag`` and ``Task`` object.
701705
$editForm->handleRequest($request);
702706

703707
if ($editForm->isSubmitted() && $editForm->isValid()) {
704-
705708
// remove the relationship between the tag and the Task
706709
foreach ($originalTags as $tag) {
707710
if (false === $task->getTags()->contains($tag)) {

0 commit comments

Comments
 (0)