infinito/application/src/Controller/SourceController.php

37 lines
1004 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 App\Source\TemplateGenerator;
use Symfony\Component\HttpFoundation\Request;
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 TemplateGenerator($source, $request);
return $this->render($templateGenerator->getTemplatePath(), ['source' => $source]);
2018-09-12 22:25:22 +02:00
}
2018-09-05 15:46:14 +02:00
}