Allow snips to be archived

This commit is contained in:
Tim
2025-05-10 16:48:03 +02:00
parent 50a7ab7985
commit 47ea226ed7
8 changed files with 107 additions and 10 deletions

View File

@ -151,4 +151,19 @@ class SnipController extends AbstractController
'form' => $form->createView(),
]);
}
#[Route('/archive/{snip}', name: '_archive')]
public function archive(Snip $snip): Response
{
$this->denyAccessUnlessGranted(SnipVoter::EDIT, $snip);
$snip->setArchived(!$snip->isArchived());
$this->repository->save($snip);
if ($snip->isArchived()) {
$this->addFlash('success', sprintf('Snip "%s" archived', $snip));
} else {
$this->addFlash('success', sprintf('Snip "%s" unarchived', $snip));
}
return $this->redirectToRoute('snip_single', ['snip' => $snip->getId()]);
}
}