infinito/application/src/Controller/NodeController.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2018-09-20 16:03:00 +02:00
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\NodeInterface;
use App\Entity\Node;
2018-10-04 20:48:12 +02:00
use Symfony\Component\HttpFoundation\RedirectResponse;
2018-09-20 16:03:00 +02:00
/**
* @todo IMPLEMENT SECURITY!
*
* @author kevinfrantz
*/
2018-10-03 18:55:33 +02:00
class NodeController extends AbstractEntityController
2018-09-20 16:03:00 +02:00
{
/**
* @Route("/node/{id}.{_format}", defaults={"_format"="html"})
*/
public function show(Request $request, int $id): Response
{
2018-10-03 18:55:33 +02:00
/**
* @var NodeInterface $node
*/
$node = $this->loadEntityById($id);
2018-09-20 16:03:00 +02:00
$view = $this->view($node, 200)
->setTemplate('node/view/standard.html.twig')
->setTemplateVar('node');
return $this->handleView($view);
}
2018-10-03 18:55:33 +02:00
2018-10-04 20:48:12 +02:00
/**
* @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);
}
2018-10-03 18:55:33 +02:00
protected function setEntityName(): void
2018-09-20 16:03:00 +02:00
{
2018-10-03 18:55:33 +02:00
$this->entityName = Node::class;
2018-09-20 16:03:00 +02:00
}
}