diff --git a/application/symfony/src/Controller/DefaultController.php b/application/symfony/src/Controller/DefaultController.php index 414ebc2..dbebcfc 100644 --- a/application/symfony/src/Controller/DefaultController.php +++ b/application/symfony/src/Controller/DefaultController.php @@ -21,6 +21,7 @@ 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/SourceRESTResponseManagerService.php b/application/symfony/src/Domain/ResponseManagement/SourceRESTResponseManagerService.php index 77aa136..1b32406 100644 --- a/application/symfony/src/Domain/ResponseManagement/SourceRESTResponseManagerService.php +++ b/application/symfony/src/Domain/ResponseManagement/SourceRESTResponseManagerService.php @@ -6,7 +6,6 @@ use Symfony\Component\HttpFoundation\Response; use App\Entity\UserInterface; use Doctrine\ORM\EntityManagerInterface; use App\Entity\Meta\RightInterface; -use App\Domain\UserManagement\UserIdentityManager; use Symfony\Component\Security\Core\User\UserInterface as CoreUserInterface; use FOS\RestBundle\View\ViewHandlerInterface; use App\Entity\Source\SourceInterface; @@ -35,13 +34,13 @@ final class SourceRESTResponseManagerService implements SourceRESTResponseManage * @var SourceInterface */ private $loadedSource; - + /** * @var UserInterface */ private $user; - public function __construct(CoreUserInterface $user,SecureSourceReadService $secureSourceRead, EntityManagerInterface $entityManager, RightInterface $requestedRight) + public function __construct(CoreUserInterface $user, SecureSourceReadService $secureSourceRead, EntityManagerInterface $entityManager, RightInterface $requestedRight) { $this->entityManager = $entityManager; $this->user = $user; @@ -72,7 +71,8 @@ final class SourceRESTResponseManagerService implements SourceRESTResponseManage } /** - * {@inheritDoc} + * {@inheritdoc} + * * @see \App\Domain\ResponseManagement\SourceRESTResponseManagerServiceInterface::getResponse() */ public function getResponse(ViewHandlerInterface $viewHandler): Response diff --git a/application/symfony/src/Domain/RightManagement/UserRight.php b/application/symfony/src/Domain/RightManagement/UserRight.php new file mode 100644 index 0000000..345c6c4 --- /dev/null +++ b/application/symfony/src/Domain/RightManagement/UserRight.php @@ -0,0 +1,47 @@ +userSourceDirector = $userSourceDirector; + } + + /** + * {@inheritdoc} + * + * @see \App\Entity\Attribut\RecieverAttributInterface::setReciever() + */ + public function setReciever(SourceInterface $reciever): void + { + throw new SetNotPossibleException('This class doesn\'t allow to set a reciever!'); + } + + /** + * {@inheritdoc} + * + * @see \App\Entity\Attribut\RecieverAttributInterface::getReciever() + */ + public function getReciever(): SourceInterface + { + return $this->userSourceDirector->getUser()->getSource(); + } +} diff --git a/application/symfony/src/Domain/RightManagement/UserRightServiceInterface.php b/application/symfony/src/Domain/RightManagement/UserRightInterface.php similarity index 54% rename from application/symfony/src/Domain/RightManagement/UserRightServiceInterface.php rename to application/symfony/src/Domain/RightManagement/UserRightInterface.php index 99d08ab..1eeab1d 100644 --- a/application/symfony/src/Domain/RightManagement/UserRightServiceInterface.php +++ b/application/symfony/src/Domain/RightManagement/UserRightInterface.php @@ -1,14 +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/UserManagement/UserIdentityServiceInterface.php b/application/symfony/src/Domain/UserManagement/UserIdentityServiceInterface.php deleted file mode 100644 index 999008e..0000000 --- a/application/symfony/src/Domain/UserManagement/UserIdentityServiceInterface.php +++ /dev/null @@ -1,12 +0,0 @@ -sourceRepository = $entityManager->getRepository(AbstractSource::class); - } - /** * @param UserInterface $user */ @@ -50,16 +41,16 @@ final class UserIdentityManager implements UserIdentityManagerInterface * @param EntityManagerInterface $entityManager * @param UserInterface $user */ - public function __construct(EntityManagerInterface $entityManager, ?UserInterface $user) + public function __construct(SourceRepository $sourceRepository, ?UserInterface $user) { - $this->setSourceRepository($entityManager); + $this->sourceRepository = $sourceRepository; $this->setUser($user); } /** * {@inheritdoc} * - * @see \App\Domain\UserManagement\UserIdentityManagerInterface::getUser() + * @see \App\Domain\UserManagement\UserSourceDirectorInterface::getUser() */ public function getUser(): UserInterface { diff --git a/application/symfony/src/Domain/UserManagement/UserIdentityManagerInterface.php b/application/symfony/src/Domain/UserManagement/UserSourceDirectorInterface.php similarity index 81% rename from application/symfony/src/Domain/UserManagement/UserIdentityManagerInterface.php rename to application/symfony/src/Domain/UserManagement/UserSourceDirectorInterface.php index 406210a..fc0c5d9 100644 --- a/application/symfony/src/Domain/UserManagement/UserIdentityManagerInterface.php +++ b/application/symfony/src/Domain/UserManagement/UserSourceDirectorInterface.php @@ -4,7 +4,7 @@ namespace App\Domain\UserManagement; use App\Entity\UserInterface; -interface UserIdentityManagerInterface +interface UserSourceDirectorInterface { /** * @return UserInterface diff --git a/application/symfony/src/Domain/UserManagement/UserIdentityService.php b/application/symfony/src/Domain/UserManagement/UserSourceDirectorService.php similarity index 52% rename from application/symfony/src/Domain/UserManagement/UserIdentityService.php rename to application/symfony/src/Domain/UserManagement/UserSourceDirectorService.php index 645777f..ea5e1a8 100644 --- a/application/symfony/src/Domain/UserManagement/UserIdentityService.php +++ b/application/symfony/src/Domain/UserManagement/UserSourceDirectorService.php @@ -1,53 +1,57 @@ entityManager = $entityManager; $this->security = $security; } - - private function setUserIdentityManager():void{ - $this->userIdentityManager = new UserIdentityManager($this->entityManager, $this->security->getUser()); + + /** + * @return UserSourceDirectorInterface + */ + private function getUserSourceDirector(): UserSourceDirectorInterface + { + $sourceRepository = $this->entityManager->getRepository(AbstractSource::class); + $user = $this->security->getUser(); + + return new UserSourceDirector($sourceRepository, $user); } - + /** * @todo Optimzed performance! - * {@inheritDoc} - * @see \App\Domain\UserManagement\UserIdentityManagerInterface::getUser() + * + * @return UserInterface */ public function getUser(): UserInterface { - $this->setUserIdentityManager(); - return $this->userIdentityManager->getUser(); + return $this->getUserSourceDirector()->getUser(); } -} \ No newline at end of file +} diff --git a/application/symfony/src/Domain/UserManagement/UserSourceDirectorServiceInterface.php b/application/symfony/src/Domain/UserManagement/UserSourceDirectorServiceInterface.php new file mode 100644 index 0000000..dc9b20e --- /dev/null +++ b/application/symfony/src/Domain/UserManagement/UserSourceDirectorServiceInterface.php @@ -0,0 +1,10 @@ +createMock(SourceInterface::class); $user->setSource($source); $userRight = new UserRightService($user); $this->assertEquals($source, $userRight->getReciever()); } - } -