mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimized Imprint function
This commit is contained in:
parent
b2642cc311
commit
89530fd6e0
@ -35,6 +35,18 @@ abstract class AbstractEntityController extends FOSRestController
|
|||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function loadEntityBySlug(string $slug): EntityInterface
|
||||||
|
{
|
||||||
|
$entity = $this->getDoctrine()
|
||||||
|
->getRepository($this->entityName)
|
||||||
|
->findOneBy(['slug' => $slug]);
|
||||||
|
if (!$entity) {
|
||||||
|
throw $this->createNotFoundException('No entity found for slug '.$slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
|
||||||
protected function redirectToRouteById(string $route, int $id): RedirectResponse
|
protected function redirectToRouteById(string $route, int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->redirectToRoute($route, [
|
return $this->redirectToRoute($route, [
|
||||||
|
@ -2,21 +2,28 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use App\DBAL\Types\SystemSlugType;
|
||||||
|
use App\Entity\Source\AbstractSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
class DefaultController extends AbstractController
|
class DefaultController extends AbstractEntityController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @todo Optimize function!
|
||||||
* @Route("/imprint", name="imprint")
|
* @Route("/imprint", name="imprint")
|
||||||
*/
|
*/
|
||||||
public function imprint(): Response
|
public function imprint(): Response
|
||||||
{
|
{
|
||||||
return $this->render('standard/imprint.html.twig');
|
$source = $this->loadEntityBySlug(SystemSlugType::IMPRINT);
|
||||||
|
$view = $this->view($source, 200)
|
||||||
|
->setTemplate('standard/imprint.html.twig')
|
||||||
|
->setTemplateVar('source');
|
||||||
|
|
||||||
|
return $this->handleView($view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,4 +33,9 @@ class DefaultController extends AbstractController
|
|||||||
{
|
{
|
||||||
return $this->render('standard/homepage.html.twig');
|
return $this->render('standard/homepage.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function setEntityName(): void
|
||||||
|
{
|
||||||
|
$this->entityName = AbstractSource::class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,5 @@ Homepage
|
|||||||
Imprint
|
Imprint
|
||||||
{% endtrans %}
|
{% endtrans %}
|
||||||
</h2>
|
</h2>
|
||||||
Developed by kevinfrantz
|
{{ source.text }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user