Allow snips to be archived
This commit is contained in:
@ -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()]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user