2018-09-05 15:46:14 +02:00
|
|
|
<?php
|
2018-09-12 23:25:22 +03:00
|
|
|
|
2018-09-05 15:46:14 +02:00
|
|
|
namespace App\Controller;
|
|
|
|
|
2018-09-05 18:17:04 +02:00
|
|
|
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;
|
2018-09-14 18:26:09 +02:00
|
|
|
use App\Source\Generator\StringGenerator;
|
2018-09-16 17:51:43 +02:00
|
|
|
use FOS\RestBundle\FOSRestBundle;
|
|
|
|
use App\Creator\Factory\Template\SourceTemplateFactory;
|
|
|
|
use FOS\RestBundle\Controller\FOSRestController;
|
|
|
|
use FOS\RestBundle\Controller\Annotations\View;
|
2018-09-05 18:17:04 +02:00
|
|
|
|
2018-09-05 15:46:14 +02:00
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
2018-09-16 17:51:43 +02:00
|
|
|
class SourceController extends FOSRestController
|
2018-09-05 15:46:14 +02:00
|
|
|
{
|
2018-09-05 18:17:04 +02:00
|
|
|
public function modify(int $id): Response
|
2018-09-12 23:25:22 +03:00
|
|
|
{
|
|
|
|
}
|
2018-09-05 18:17:04 +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 23:25:22 +03: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);
|
|
|
|
}
|
2018-09-16 17:51:43 +02:00
|
|
|
$view = $this->view($source, 200)
|
|
|
|
->setTemplate((new SourceTemplateFactory($source, $request))->getTemplatePath())
|
|
|
|
->setTemplateVar('source');
|
|
|
|
return $this->handleView($view);
|
2018-09-12 23:25:22 +03:00
|
|
|
}
|
2018-09-05 15:46:14 +02:00
|
|
|
}
|