mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Implemented routing for law show
This commit is contained in:
parent
65c4aea7c8
commit
379e9c62e9
@ -3,6 +3,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\EntityInterface;
|
||||
use FOS\RestBundle\Controller\FOSRestController;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -32,4 +33,11 @@ abstract class AbstractEntityController extends FOSRestController
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
|
||||
protected function redirectToRouteById(string $route, int $id): RedirectResponse
|
||||
{
|
||||
return $this->redirectToRoute($route, [
|
||||
'id' => $id
|
||||
]);
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use App\Entity\NodeInterface;
|
||||
use App\Entity\Node;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
/**
|
||||
* @todo IMPLEMENT SECURITY!
|
||||
@ -30,6 +31,15 @@ class NodeController extends AbstractEntityController
|
||||
return $this->handleView($view);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/node/{id}/law.{_format}", defaults={"_format"="html"})
|
||||
*/
|
||||
public function law(int $id): RedirectResponse
|
||||
{
|
||||
$lawId = $this->loadEntityById($id)->getLaw()->getId();
|
||||
return $this->redirectToRouteById('app_law_show',$lawId);
|
||||
}
|
||||
|
||||
protected function setEntityName(): void
|
||||
{
|
||||
$this->entityName = Node::class;
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@ -13,22 +12,26 @@ use App\Creator\Factory\Template\Source\SourceTemplateFormFactory;
|
||||
use App\Creator\Factory\Form\Source\SourceFormFactory;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Entity\NodeInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @todo IMPLEMENT SECURITY!
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SourceController extends AbstractEntityController
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @Route("/source/{id}.{_format}", defaults={"_format"="html"})
|
||||
*/
|
||||
public function show(Request $request, int $id): Response
|
||||
{
|
||||
$source = $this->loadEntityById($id);
|
||||
#$assembler = $this->get(SourceDTOAssember::class);
|
||||
#$dto = $assembler->build($source, $this->getUser());
|
||||
// $assembler = $this->get(SourceDTOAssember::class);
|
||||
// $dto = $assembler->build($source, $this->getUser());
|
||||
$view = $this->view($source, 200)
|
||||
->setTemplate((new SourceTemplateFactory($source, $request))->getTemplatePath())
|
||||
->setTemplateVar('source');
|
||||
@ -37,6 +40,7 @@ class SourceController extends AbstractEntityController
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @Route("/source/{id}/edit.{_format}", defaults={"_format"="html"})
|
||||
*/
|
||||
public function edit(Request $request, int $id): Response
|
||||
@ -50,17 +54,22 @@ class SourceController extends AbstractEntityController
|
||||
}
|
||||
|
||||
return $this->render((new SourceTemplateFormFactory($source, $request))->getTemplatePath(), [
|
||||
'form' => $form->createView(),
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @Route("/source/{id}/node.{_format}", defaults={"_format"="html"})
|
||||
*/
|
||||
public function node(Request $request, int $id): RedirectResponse
|
||||
public function node(int $id): RedirectResponse
|
||||
{
|
||||
$source = $this->loadEntityById($id);
|
||||
return $this->redirectToRoute('app_node_show', ['id' => $source->getNode()->getId()]);
|
||||
$nodeId = $this->loadNodeById($id)->getId();
|
||||
return $this->redirectToRouteById('app_node_show',$nodeId);
|
||||
}
|
||||
|
||||
private function loadNodeById(int $id):NodeInterface{
|
||||
return $this->loadEntityById($id)->getNode();
|
||||
}
|
||||
|
||||
private function saveSource(SourceInterface $source): void
|
||||
@ -74,5 +83,4 @@ class SourceController extends AbstractEntityController
|
||||
{
|
||||
$this->entityName = AbstractSource::class;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user