infinito/application/src/Controller/NodeController.php

71 lines
1.6 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;
2018-10-04 20:48:12 +02:00
use Symfony\Component\HttpFoundation\RedirectResponse;
2018-10-28 22:49:57 +01:00
use App\Entity\Meta\RelationInterface;
use App\Entity\Meta\Relation;
2018-09-20 16:03:00 +02:00
/**
* @todo IMPLEMENT SECURITY!
2018-10-28 22:49:57 +01:00
* @todo Refactor!
2018-10-29 19:01:00 +01:00
*
2018-09-20 16:03:00 +02:00
* @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
/**
2018-10-29 19:01:00 +01:00
* @var RelationInterface
2018-10-03 18:55:33 +02:00
*/
2018-10-28 22:49:57 +01:00
$relation = $this->loadEntityById($id);
$view = $this->view($relation, 200)
2018-09-20 16:03:00 +02:00
->setTemplate('node/view/standard.html.twig')
->setTemplateVar('node');
2018-10-29 19:01:00 +01:00
2018-09-20 16:03:00 +02:00
return $this->handleView($view);
}
2018-10-29 19:01:00 +01: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();
2018-10-29 19:01:00 +01:00
return $this->redirectToRouteById('app_law_show', $lawId);
2018-10-04 20:48:12 +02:00
}
2018-10-29 19:01:00 +01:00
2018-10-04 22:39:26 +02:00
/**
* @Route("/node/{id}/parents.{_format}", defaults={"_format"="html"})
*/
2018-10-29 19:01:00 +01:00
public function parents(int $id): Response
{
/*
2018-10-04 22:39:26 +02:00
* @todo Implement
*/
}
2018-10-29 19:01:00 +01:00
2018-10-04 22:39:26 +02:00
/**
* @Route("/node/{id}/childs.{_format}", defaults={"_format"="html"})
*/
2018-10-29 19:01:00 +01:00
public function childs(int $id): Response
{
/*
2018-10-04 22:39:26 +02:00
* @todo Implement
*/
}
2018-10-29 19:01:00 +01:00
2018-10-03 18:55:33 +02:00
protected function setEntityName(): void
2018-09-20 16:03:00 +02:00
{
2018-10-28 22:49:57 +01:00
$this->entityName = Relation::class;
2018-09-20 16:03:00 +02:00
}
}