infinito/application/src/Controller/DefaultController.php

65 lines
1.9 KiB
PHP
Raw Normal View History

2018-09-05 09:11:08 +02:00
<?php
2018-09-12 22:25:22 +02:00
2018-09-05 09:11:08 +02:00
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
2018-11-23 23:22:17 +01:00
use App\DBAL\Types\SystemSlugType;
use App\Entity\Source\AbstractSource;
2019-01-03 22:56:31 +01:00
use App\Entity\User;
use App\Domain\SecureLoadManagement\SecureSourceLoader;
use App\Entity\Meta\Right;
use App\DBAL\Types\LayerType;
use App\DBAL\Types\RightType;
2018-09-05 09:11:08 +02:00
/**
* This controller offers the standart routes for the template.
*
2018-09-05 09:11:08 +02:00
* @author kevinfrantz
*/
2018-11-23 23:22:17 +01:00
class DefaultController extends AbstractEntityController
2018-09-05 09:11:08 +02:00
{
2018-09-05 18:11:35 +02:00
/**
2018-11-23 23:22:17 +01:00
* @todo Optimize function!
2018-09-05 18:11:35 +02:00
* @Route("/imprint", name="imprint")
*/
2018-09-05 09:11:08 +02:00
public function imprint(): Response
{
2019-01-03 22:56:31 +01:00
if ($this->getUser()) {
$user = $this->getUser();
} else {
$user = new User();
$user->setSource($this->getDoctrine()
->getRepository(AbstractSource::class)
->findOneBy(['slug' => SystemSlugType::GUEST_USER]));
}
$requestedSource = new class() extends AbstractSource {
};
$requestedSource->setSlug(SystemSlugType::IMPRINT);
$requestedRight = new Right();
$requestedRight->setSource($requestedSource);
$requestedRight->setReciever($user->getSource());
$requestedRight->setLayer(LayerType::SOURCE);
$requestedRight->setType(RightType::READ);
$secureSourceLoader = new SecureSourceLoader($this->getDoctrine()->getManager(), $requestedRight);
$view = $this->view($secureSourceLoader->getSource(), 200)
2018-11-23 23:22:17 +01:00
->setTemplate('standard/imprint.html.twig')
->setTemplateVar('source');
return $this->handleView($view);
2018-09-05 09:11:08 +02:00
}
2018-09-12 22:25:22 +02:00
2018-09-05 09:11:08 +02:00
/**
* @Route("/", name="homepage")
*/
public function homepage(): Response
{
2018-09-12 22:25:22 +02:00
return $this->render('standard/homepage.html.twig');
2018-09-05 09:11:08 +02:00
}
2018-11-23 23:22:17 +01:00
protected function setEntityName(): void
{
$this->entityName = AbstractSource::class;
}
2018-09-05 09:11:08 +02:00
}