Change snip and tag entities to public columns
This commit is contained in:
@@ -34,11 +34,11 @@ class ApiController extends AbstractApiController
|
||||
$this->denyAccessUnlessGranted(SnipVoter::VIEW, $snip);
|
||||
|
||||
return $this->successResponse([
|
||||
'id' => $snip->getId(),
|
||||
'id' => $snip->id,
|
||||
'content' => $snip->getActiveText(),
|
||||
'createdBy' => [
|
||||
'id' => $snip->getCreatedBy()->getId(),
|
||||
'name' => $snip->getCreatedBy()->getName(),
|
||||
'id' => $snip->createdBy->getId(),
|
||||
'name' => $snip->createdBy->getName(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class ApiController extends AbstractApiController
|
||||
{
|
||||
$this->denyAccessUnlessGranted(SnipVoter::EDIT, $snip);
|
||||
|
||||
if (!($snip->getActiveVersion() === $snip->getLatestVersion())) {
|
||||
if (!($snip->activeVersion === $snip->getLatestVersion())) {
|
||||
return $this->errorResponse('Snip is not the latest version');
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ class ApiController extends AbstractApiController
|
||||
}
|
||||
|
||||
return $this->successResponse([
|
||||
'id' => $snip->getId(),
|
||||
'name' => $snip->getName(),
|
||||
'id' => $snip->id,
|
||||
'name' => $snip->name,
|
||||
'content' => $snip->getActiveText(),
|
||||
'createdBy' => [
|
||||
'id' => $snip->getCreatedBy()->getId(),
|
||||
'name' => $snip->getCreatedBy()->getName(),
|
||||
'id' => $snip->createdBy->getId(),
|
||||
'name' => $snip->createdBy->getName(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -85,21 +85,20 @@ class SnipController extends AbstractController
|
||||
* Temporary solution to prevent editing of old versions
|
||||
* It technically fully works, but rendering the version history needs an update first
|
||||
*/
|
||||
$isLatest = $snip->getActiveVersion() === $snip->getLatestVersion();
|
||||
$isLatest = $snip->activeVersion === $snip->getLatestVersion();
|
||||
if (!$isLatest) {
|
||||
$this->addFlash('error', 'Snip is not the latest version, changes will not be saved.');
|
||||
}
|
||||
|
||||
$form = $this->createForm(SnipType::class, $snip)
|
||||
->add('Save', SubmitType::class)
|
||||
;
|
||||
->add('Save', SubmitType::class);
|
||||
$form->get('content')->setData($snip->getActiveText());
|
||||
|
||||
$form->handleRequest($request);
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
if (!$isLatest) {
|
||||
return $this->redirectToRoute('snip_single', [
|
||||
'snip' => $snip->getId(),
|
||||
'snip' => $snip->id,
|
||||
]);
|
||||
}
|
||||
$this->repository->save($snip);
|
||||
@@ -112,7 +111,7 @@ class SnipController extends AbstractController
|
||||
$this->addFlash('success', sprintf('Snip "%s" saved', $snip));
|
||||
|
||||
return $this->redirectToRoute('snip_single', [
|
||||
'snip' => $snip->getId(),
|
||||
'snip' => $snip->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -126,9 +125,8 @@ class SnipController extends AbstractController
|
||||
public function new(Request $request, SnipContentService $contentService): Response
|
||||
{
|
||||
$snip = new Snip();
|
||||
$snip->setCreatedAtNow()
|
||||
->setCreatedBy($this->getUser())
|
||||
;
|
||||
$snip->setCreatedAtNow();
|
||||
$snip->createdBy = $this->getUser();
|
||||
|
||||
$form = $this->createForm(SnipType::class, $snip);
|
||||
$form->add('Create', SubmitType::class);
|
||||
@@ -145,7 +143,7 @@ class SnipController extends AbstractController
|
||||
$this->addFlash('success', sprintf('Snip "%s" created', $snip));
|
||||
|
||||
return $this->redirectToRoute('snip_single', [
|
||||
'snip' => $snip->getId(),
|
||||
'snip' => $snip->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -163,7 +161,7 @@ class SnipController extends AbstractController
|
||||
$form = $this->createForm(ConfirmationType::class);
|
||||
$form->handleRequest($request);
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$snip->setActiveVersion(null);
|
||||
$snip->activeVersion = null;
|
||||
$this->repository->save($snip);
|
||||
$this->repository->remove($snip);
|
||||
$this->addFlash('success', sprintf('Snip "%s" deleted', $snip));
|
||||
@@ -180,14 +178,14 @@ class SnipController extends AbstractController
|
||||
public function archive(Snip $snip): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(SnipVoter::EDIT, $snip);
|
||||
$snip->setArchived(!$snip->isArchived());
|
||||
$snip->archived = !$snip->archived;
|
||||
$this->repository->save($snip);
|
||||
if ($snip->isArchived()) {
|
||||
if ($snip->archived) {
|
||||
$this->addFlash('success', sprintf('Snip "%s" archived', $snip));
|
||||
} else {
|
||||
$this->addFlash('success', sprintf('Snip "%s" unarchived', $snip));
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('snip_edit', ['snip' => $snip->getId()]);
|
||||
return $this->redirectToRoute('snip_edit', ['snip' => $snip->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ class VersionController extends AbstractController
|
||||
public function index(Snip $snip): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(SnipVoter::EDIT, $snip);
|
||||
|
||||
|
||||
return $this->render('version/index.html.twig', [
|
||||
'snip' => $snip,
|
||||
]);
|
||||
@@ -34,6 +34,6 @@ class VersionController extends AbstractController
|
||||
|
||||
$this->contentService->setVersion($snip, $version);
|
||||
$this->addFlash('success', 'Snip version set to ' . $version->getId());
|
||||
return $this->redirectToRoute('snip_single', ['snip' => $snip->getId()]);
|
||||
return $this->redirectToRoute('snip_single', ['snip' => $snip->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user