Fix snip deletion

This commit is contained in:
Tim 2025-05-05 01:16:21 +02:00
parent f52058c250
commit 06def04cae
3 changed files with 3 additions and 9 deletions

View File

@ -1,5 +1,5 @@
{ {
"dev": { "dev": {
"host": "http://snips.local.loken.nl" "host": "https://snips.localhost"
} }
} }

View File

@ -139,7 +139,8 @@ class SnipController extends AbstractController
$form = $this->createForm(ConfirmationType::class); $form = $this->createForm(ConfirmationType::class);
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$this->contentService->delete($snip); $snip->setActiveVersion(null);
$this->repository->save($snip);
$this->repository->remove($snip); $this->repository->remove($snip);
$this->addFlash('success', sprintf('Snip "%s" deleted', $snip)); $this->addFlash('success', sprintf('Snip "%s" deleted', $snip));
return $this->redirectToRoute('snip_index'); return $this->redirectToRoute('snip_index');

View File

@ -98,11 +98,4 @@ readonly class SnipContentService
$this->em->persist($content); $this->em->persist($content);
$this->em->flush(); $this->em->flush();
} }
public function delete(Snip $snip): void
{
foreach ($snip->getSnipContents() as $snipContent) {
$this->em->remove($snipContent);
}
}
} }