Start on removing git and better integrate db

This commit is contained in:
Tim
2023-12-18 01:26:44 +01:00
parent dd55126ac2
commit 64bd7e3642
17 changed files with 58 additions and 304 deletions

View File

@ -49,11 +49,12 @@ class SnipController extends AbstractController
$this->denyAccessUnlessGranted(SnipVoter::VIEW, $snip);
$snipService = $this->snipServiceFactory->create($snip);
dump($snipService);
return $this->render('snip/single.html.twig', [
'snip' => $snip,
'content' => $pl->parse($snipService->get()),
'branch' => $snipService->getCommit(),
'content' => $pl->parse($snipService->getActiveText()),
'activeVersion' => $snipService->getActiveVersion(),
'latestVersion' => $snipService->getLatestVersion(),
]);
}
@ -63,7 +64,7 @@ class SnipController extends AbstractController
$this->denyAccessUnlessGranted(SnipVoter::VIEW, $snip);
$response = new Response(
$pl->clean($this->snipServiceFactory->create($snip)->get()),
$pl->clean($this->snipServiceFactory->create($snip)->getActiveText()),
Response::HTTP_OK,
['Content-Type' => 'text/html']
);
@ -88,7 +89,7 @@ class SnipController extends AbstractController
$form = $this->createForm(SnipType::class, $snip);
$form->add('Save', SubmitType::class);
if ($snip->getId()) {
$form->get('content')->setData($this->snipServiceFactory->create($snip)->get());
$form->get('content')->setData($this->snipServiceFactory->create($snip)->getActiveText());
}
$form->handleRequest($request);

View File

@ -3,14 +3,15 @@
namespace App\Controller;
use App\Entity\Snip;
use App\Entity\SnipContent;
use App\Security\Voter\SnipVoter;
use App\Service\SnipServiceFactory;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route('/history/{snip}', name: 'history')]
class HistoryController extends AbstractController
#[Route('/version/{snip}', name: 'version')]
class VersionController extends AbstractController
{
public function __construct(
private readonly SnipServiceFactory $snipServiceFactory,
@ -22,7 +23,7 @@ class HistoryController extends AbstractController
$this->denyAccessUnlessGranted(SnipVoter::EDIT, $snip);
$snipService = $this->snipServiceFactory->create($snip);
return $this->render('history/index.html.twig', [
return $this->render('version/index.html.twig', [
'snip' => $snip,
'versions' => $snipService->getVersions(),
'latestVersion' => $snipService->getLatestVersion(),
@ -30,12 +31,12 @@ class HistoryController extends AbstractController
}
#[Route('/set/{version}', name: '_set')]
public function set(Snip $snip, string $version): Response
public function set(Snip $snip, SnipContent $version): Response
{
$this->denyAccessUnlessGranted(SnipVoter::EDIT, $snip);
$this->snipServiceFactory->create($snip)->setVersion($version);
$this->addFlash('success', 'Snip version set to ' . $version);
$this->snipServiceFactory->create($snip)->setVersion($version->getId());
$this->addFlash('success', 'Snip version set to ' . $version->getId());
return $this->redirectToRoute('snip_single', ['snip' => $snip->getId()]);
}
}