Allow code in-lining instead of everything

Create snip content parser
This commit is contained in:
Tim
2023-04-06 22:50:54 +02:00
parent f20608082a
commit bf63b7a274
7 changed files with 134 additions and 5 deletions

View File

@ -7,6 +7,7 @@ use App\Form\ConfirmationType;
use App\Form\SnipType;
use App\Repository\SnipRepository;
use App\Security\Voter\SnipVoter;
use App\Service\SnipParser\Pipeline;
use App\Service\SnipServiceFactory;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@ -29,7 +30,7 @@ class SnipController extends AbstractController
{
return $this->render('snip/index.html.twig', [
'snips' => $this->repository->findByUser($this->getUser()),
'title' => 'My Snips'
'title' => 'My Snips',
]);
}
@ -38,18 +39,21 @@ class SnipController extends AbstractController
{
return $this->render('snip/index.html.twig', [
'snips' => $this->repository->findPublic($this->getUser()),
'title' => 'Public Snips'
'title' => 'Public Snips',
]);
}
#[Route('/single/{snip}', name: '_single')]
public function single(Snip $snip): Response
{
$snipParser = new Pipeline();
$this->denyAccessUnlessGranted(SnipVoter::VIEW, $snip);
$snipService = $this->snipServiceFactory->create($snip);
$content = $snipParser->parse(($snipService->get()));
dump($content);
return $this->render('snip/single.html.twig', [
'snip' => $snip,
'content' => $snipService->get(),
'content' => $content,
'branch' => $snipService->getRepo()->getCurrentBranchName(),
]);
}