infinito/application/src/Controller/SourceController.php

37 lines
1008 B
PHP
Raw Normal View History

2018-09-05 15:46:14 +02:00
<?php
2018-09-12 22:25:22 +02:00
2018-09-05 15:46:14 +02:00
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
2018-09-14 16:05:47 +02:00
use App\Entity\AbstractSource;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use App\Source\Generator\StringGenerator;
2018-09-05 15:46:14 +02:00
/**
* @author kevinfrantz
*/
2018-09-14 16:05:47 +02:00
class SourceController extends AbstractController
2018-09-05 15:46:14 +02:00
{
public function modify(int $id): Response
2018-09-12 22:25:22 +02:00
{
}
2018-09-14 16:05:47 +02:00
/**
* @Route("/source/{id}.{_format}", defaults={"_format"="html"})
*/
public function show(Request $request, int $id): Response
2018-09-12 22:25:22 +02:00
{
2018-09-14 16:05:47 +02:00
$source = $this->getDoctrine()
->getRepository(AbstractSource::class)
->find($id);
if (!$source) {
throw $this->createNotFoundException('No source found for id '.$id);
}
$templateGenerator = new StringGenerator($request, $source, $this->container->get('twig'));
2018-09-14 16:05:47 +02:00
return new Response($templateGenerator->render());
2018-09-12 22:25:22 +02:00
}
2018-09-05 15:46:14 +02:00
}