diff --git a/application/symfony/src/Controller/DefaultController.php b/application/symfony/src/Controller/DefaultController.php index 34502f1..414ebc2 100644 --- a/application/symfony/src/Controller/DefaultController.php +++ b/application/symfony/src/Controller/DefaultController.php @@ -20,6 +20,7 @@ use App\Domain\ResponseManagement\SourceRESTResponseManager; final class DefaultController extends AbstractController { /** + * @deprecated Use load via source instead of fixed route * @todo Optimize function! * @Route("/imprint.{_format}", defaults={"_format"="json"}, name="imprint") */ diff --git a/application/symfony/src/Domain/ResponseManagement/SourceRESTResponseManagerInterface.php b/application/symfony/src/Domain/ResponseManagement/SourceRESTResponseManagerInterface.php deleted file mode 100644 index 25cc7bd..0000000 --- a/application/symfony/src/Domain/ResponseManagement/SourceRESTResponseManagerInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -entityManager = $entityManager; - $this->viewHandler = $viewHandler; - $this->setUser($user); + $this->user = $user; $this->setRequestedRight($requestedRight); $this->setLoadedSource(); $this->setView(); @@ -71,21 +55,6 @@ final class SourceRESTResponseManager implements SourceRESTResponseManagerInterf $this->view = new View($this->loadedSource, 200); } - private function setLoadedSource(): void - { - $secureSourceLoader = new SecureSourceReadService($this->entityManager, $this->requestedRight); - $this->loadedSource = $secureSourceLoader->getSource(); - } - - /** - * @param UserInterface $user - */ - private function setUser(?UserInterface $user): void - { - $userIdentityManager = new UserIdentityManager($this->entityManager, $user); - $this->user = $userIdentityManager->getUser(); - } - /** * @param RightInterface $requestedRight * @@ -103,12 +72,11 @@ final class SourceRESTResponseManager implements SourceRESTResponseManagerInterf } /** - * {@inheritdoc} - * - * @see \App\Domain\ResponseManagement\SourceRESTResponseManagerInterface::getResponse() + * {@inheritDoc} + * @see \App\Domain\ResponseManagement\SourceRESTResponseManagerServiceInterface::getResponse() */ - public function getResponse(): Response + public function getResponse(ViewHandlerInterface $viewHandler): Response { - return $this->viewHandler->handle($this->view); + return $viewHandler->handle($this->view); } } diff --git a/application/symfony/src/Domain/ResponseManagement/SourceRESTResponseManagerServiceInterface.php b/application/symfony/src/Domain/ResponseManagement/SourceRESTResponseManagerServiceInterface.php new file mode 100644 index 0000000..18ffed3 --- /dev/null +++ b/application/symfony/src/Domain/ResponseManagement/SourceRESTResponseManagerServiceInterface.php @@ -0,0 +1,14 @@ +security = $security; + } + + /** + * {@inheritDoc} + * @see \App\Entity\Attribut\RecieverAttributInterface::setReciever() + */ + public function setReciever(SourceInterface $reciever):void{ + + } + + public function getReciever():SourceInterface{ + return $this->user->getSource(); + } +} + diff --git a/application/symfony/src/Domain/RightManagement/UserRightServiceInterface.php b/application/symfony/src/Domain/RightManagement/UserRightServiceInterface.php new file mode 100644 index 0000000..99d08ab --- /dev/null +++ b/application/symfony/src/Domain/RightManagement/UserRightServiceInterface.php @@ -0,0 +1,14 @@ +entityManager = $entityManager; + $this->security = $security; + } + + private function setUserIdentityManager():void{ + $this->userIdentityManager = new UserIdentityManager($this->entityManager, $this->security->getUser()); + } + + /** + * @todo Optimzed performance! + * {@inheritDoc} + * @see \App\Domain\UserManagement\UserIdentityManagerInterface::getUser() + */ + public function getUser(): UserInterface + { + $this->setUserIdentityManager(); + return $this->userIdentityManager->getUser(); + } +} \ No newline at end of file diff --git a/application/symfony/src/Domain/UserManagement/UserIdentityServiceInterface.php b/application/symfony/src/Domain/UserManagement/UserIdentityServiceInterface.php new file mode 100644 index 0000000..999008e --- /dev/null +++ b/application/symfony/src/Domain/UserManagement/UserIdentityServiceInterface.php @@ -0,0 +1,12 @@ +createMock(SourceInterface::class); + $user->setSource($source); + $userRight = new UserRightService($user); + $this->assertEquals($source, $userRight->getReciever()); + } + +} +