Integrate snipContent more tightly into snip and cleanup old code

This commit is contained in:
Tim
2023-12-20 22:37:06 +01:00
parent 64bd7e3642
commit 5624fc3a74
9 changed files with 67 additions and 45 deletions

View File

@ -53,8 +53,6 @@ class SnipController extends AbstractController
return $this->render('snip/single.html.twig', [
'snip' => $snip,
'content' => $pl->parse($snipService->getActiveText()),
'activeVersion' => $snipService->getActiveVersion(),
'latestVersion' => $snipService->getLatestVersion(),
]);
}
@ -114,7 +112,7 @@ class SnipController extends AbstractController
public function new(Request $request): Response
{
$snip = new Snip();
$snip->setCreatedAtTodayNoSeconds()
$snip->setCreatedAtNow()
->setCreatedBy($this->getUser());
return $this->edit($snip, $request);

View File

@ -21,12 +21,9 @@ class VersionController extends AbstractController
public function index(Snip $snip): Response
{
$this->denyAccessUnlessGranted(SnipVoter::EDIT, $snip);
$snipService = $this->snipServiceFactory->create($snip);
return $this->render('version/index.html.twig', [
'snip' => $snip,
'versions' => $snipService->getVersions(),
'latestVersion' => $snipService->getLatestVersion(),
]);
}
@ -35,7 +32,7 @@ class VersionController extends AbstractController
{
$this->denyAccessUnlessGranted(SnipVoter::EDIT, $snip);
$this->snipServiceFactory->create($snip)->setVersion($version->getId());
$this->snipServiceFactory->create($snip)->setVersion($version);
$this->addFlash('success', 'Snip version set to ' . $version->getId());
return $this->redirectToRoute('snip_single', ['snip' => $snip->getId()]);
}