diff --git a/application/src/Controller/NodeController.php b/application/src/Controller/NodeController.php new file mode 100644 index 0000000..2a5b634 --- /dev/null +++ b/application/src/Controller/NodeController.php @@ -0,0 +1,43 @@ +loadSource($request, $id); + $view = $this->view($node, 200) + ->setTemplate('node/view/standard.html.twig') + ->setTemplateVar('node'); + + return $this->handleView($view); + } + + private function loadSource(Request $request, int $id): NodeInterface + { + $node = $this->getDoctrine() + ->getRepository(Node::class) + ->find($id); + if (!$node) { + throw $this->createNotFoundException('No node found for id '.$id); + } + + return $node; + } +} diff --git a/application/src/Controller/SourceController.php b/application/src/Controller/SourceController.php index e0477c9..86e265a 100644 --- a/application/src/Controller/SourceController.php +++ b/application/src/Controller/SourceController.php @@ -11,6 +11,7 @@ use FOS\RestBundle\Controller\FOSRestController; use App\Entity\SourceInterface; use App\Creator\Factory\Template\Source\SourceTemplateFormFactory; use App\Creator\Factory\Form\Source\SourceFormFactory; +use Symfony\Component\HttpFoundation\RedirectResponse; /** * @todo IMPLEMENT SECURITY! @@ -50,6 +51,16 @@ class SourceController extends FOSRestController ]); } + /** + * @Route("/source/{id}/node.{_format}", defaults={"_format"="html"}) + */ + public function node(Request $request, int $id): RedirectResponse + { + $source = $this->loadSource($request, $id); + + return $this->redirectToRoute('app_node_show', ['id' => $source->getNode()->getId()]); + } + private function loadSource(Request $request, int $id): SourceInterface { $source = $this->getDoctrine() diff --git a/application/src/Entity/Node.php b/application/src/Entity/Node.php index 44b215a..d755a38 100644 --- a/application/src/Entity/Node.php +++ b/application/src/Entity/Node.php @@ -12,7 +12,7 @@ use App\Entity\Attribut\LawAttribut; /** * @author kevinfrantz * @ORM\Table(name="node") - * @ORM\Entity(repositoryClass="App\Repository\NodeRepository") + * @ORM\Entity() */ class Node extends AbstractEntity implements NodeInterface { diff --git a/application/src/Subscriber/SourceMenuSubscriber.php b/application/src/Subscriber/SourceMenuSubscriber.php index 345e654..40466b5 100644 --- a/application/src/Subscriber/SourceMenuSubscriber.php +++ b/application/src/Subscriber/SourceMenuSubscriber.php @@ -39,6 +39,15 @@ class SourceMenuSubscriber implements EventSubscriberInterface ], ]); $this->generateSourceFormatDropdown($menu, $event); + $menu->addChild($this->translator->trans('node'), [ + 'route' => 'app_source_node', + 'routeParameters' => [ + 'id' => $event->getRequest()->getCurrentRequest()->attributes->get('id'), + ], + 'attributes' => [ + 'icon' => 'fas fa-globe', + ], + ]); } private function generateSourceFormatDropdown(ItemInterface $menu, SourceMenuEvent $event): void diff --git a/application/templates/node/node.html.twig b/application/templates/node/node.html.twig new file mode 100644 index 0000000..e1d49a7 --- /dev/null +++ b/application/templates/node/node.html.twig @@ -0,0 +1,6 @@ +{% extends "frames/default.html.twig" %} +{% block title %} + {% trans %} + Node + {% endtrans %} +{% endblock %} \ No newline at end of file diff --git a/application/templates/node/structure/_list.html.twig b/application/templates/node/structure/_list.html.twig new file mode 100644 index 0000000..8f75ea5 --- /dev/null +++ b/application/templates/node/structure/_list.html.twig @@ -0,0 +1,13 @@ +{% if nodeList.isEmpty %} +{% trans %} +This list doesn't contain elements. +{% endtrans %} +{% else %} +