Implement snip hiding

This commit is contained in:
Tim
2025-04-25 22:17:27 +02:00
parent 5a940b9ebd
commit 7c4a2b46c0
13 changed files with 541 additions and 24 deletions

View File

@ -2,6 +2,7 @@
namespace App\Controller;
use App\Dto\SnipFilterRequest;
use App\Entity\Snip;
use App\Form\ConfirmationType;
use App\Form\SnipType;
@ -13,6 +14,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
#[Route('/snip', name: 'snip')]
@ -24,20 +26,19 @@ class SnipController extends AbstractController
) {}
#[Route('/', name: '_index')]
public function index(): Response
public function index(#[MapQueryString] SnipFilterRequest $request): Response
{
return $this->render('snip/index.html.twig', [
'snips' => $this->repository->findByUser($this->getUser()),
'title' => 'My Snips',
'snips' => $this->repository->findByRequest($this->getUser(), $request),
'request' => $request,
]);
}
#[Route('/public', name: '_public')]
public function public(): Response
{
return $this->render('snip/index.html.twig', [
return $this->render('snip/public.html.twig', [
'snips' => $this->repository->findPublic(),
'title' => 'Public Snips',
]);
}
@ -86,7 +87,7 @@ class SnipController extends AbstractController
* It technically fully works, but rendering the version history needs an update first
*/
$isLatest = $snip->getActiveVersion() === $snip->getLatestVersion();
if(!$isLatest) {
if (!$isLatest) {
$this->addFlash('error', 'Snip is not the latest version, changes will not be saved.');
}