Implemented SourceRESTResponseManager and cleaned up code

This commit is contained in:
Kevin Frantz
2019-01-05 11:37:36 +01:00
parent e9f4931a5e
commit 843733ad79
10 changed files with 210 additions and 25 deletions

View File

@@ -6,13 +6,12 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use App\DBAL\Types\SystemSlugType;
use App\Entity\Source\AbstractSource;
use App\Domain\SecureLoadManagement\SecureSourceLoader;
use App\Entity\Meta\Right;
use App\DBAL\Types\LayerType;
use App\DBAL\Types\RightType;
use App\Domain\UserManagement\UserIdentityManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Source\PureSource;
use App\Domain\ResponseManagement\SourceRESTResponseManager;
/**
* This controller offers the standart routes for the template.
@@ -23,25 +22,19 @@ final class DefaultController extends AbstractEntityController
{
/**
* @todo Optimize function!
* @Route("/imprint", name="imprint")
* @Route("/imprint.{_format}", defaults={"_format"="json"}, name="imprint")
*/
public function imprint(EntityManagerInterface $entityManager): Response
{
$userIdentityManager = new UserIdentityManager($entityManager, $this->getUser());
$user = $userIdentityManager->getUser();
$requestedSource = new PureSource();
$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)
->setTemplate('standard/imprint.html.twig')
->setTemplateVar('source');
$sourceResponseManager = new SourceRESTResponseManager($this->getUser(), $entityManager, $requestedRight, $this->getViewHandler());
return $this->handleView($view);
return $sourceResponseManager->getResponse();
}
/**