diff --git a/application/symfony/src/Domain/RightManagement/RightRequestManagement/RequestedRight.php b/application/symfony/src/Domain/RightManagement/RightRequestManagement/RequestedRight.php new file mode 100644 index 0000000..d8951c2 --- /dev/null +++ b/application/symfony/src/Domain/RightManagement/RightRequestManagement/RequestedRight.php @@ -0,0 +1,106 @@ +sourceRepository = $sourceRepository; + } + + private function loadSource(): void + { + $this->source = $this->sourceRepository->findOneByIdOrSlug($this->requestedSource); + } + + /** + * @return bool + */ + private function isIdEquals(): bool + { + if ($this->requestedSource->hasId() && $this->source->hasId()) { + return false; + } + + return $this->requestedSource->getId() === $this->source->getId(); + } + + /** + * @return bool + */ + private function isSlugEquals(): bool + { + if ($this->requestedSource->hasSlug() && $this->source->hasSlug()) { + return false; + } + + return $this->requestedSource->getSlug() === $this->source->getSlug(); + } + + /** + * @return bool Tells if a reload of the source is neccessary + */ + private function isReloadNeccessary(): bool + { + return $this->isIdEquals() && $this->isSlugEquals(); + } + + /** + * Uses some kind of Lazy loading. + * + * @see https://en.wikipedia.org/wiki/Lazy_loading + * {@inheritdoc} + * @see \App\Domain\RightManagement\RightRequestManagement\RequestedRightInterface::getSource() + */ + final public function getSource(): SourceInterface + { + if ($this->isReloadNeccessary()) { + $this->loadSource(); + } + + return $this->source; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\RightManagement\RightRequestManagement\RequestedRightInterface::setRequestedSource() + */ + final public function setRequestedSource(RequestedSourceInterface $requestedSource) + { + $this->requestedSource = $requestedSource; + $this->loadSource(); + } +} diff --git a/application/symfony/src/Domain/RightManagement/RightRequestManagement/RequestedRightInterface.php b/application/symfony/src/Domain/RightManagement/RightRequestManagement/RequestedRightInterface.php new file mode 100644 index 0000000..54007af --- /dev/null +++ b/application/symfony/src/Domain/RightManagement/RightRequestManagement/RequestedRightInterface.php @@ -0,0 +1,27 @@ +userSourceDirector = $userSourceDirector; + $this->requestedRight = $requestedRight; + } + + /** + * {@inheritdoc} + * + * @see \App\Entity\Attribut\RecieverAttributInterface::setReciever() + */ + public function setReciever(SourceInterface $reciever): void + { + $this->requestedRight->setReciever($reciever); + } + + /** + * {@inheritdoc} + * + * @see \App\Entity\Attribut\RecieverAttributInterface::getReciever() + */ + public function getReciever(): SourceInterface + { + return $this->userSourceDirector->getUser()->getSource(); + } + + /** + * {@inheritdoc} + * + * @see \App\Entity\Attribut\LayerAttributInterface::setLayer() + */ + public function setLayer(string $layer): void + { + $this->requestedRight->setLayer($layer); + } + + /** + * {@inheritdoc} + * + * @see \App\Entity\Attribut\TypeAttributInterface::getType() + */ + public function getType(): string + { + return $this->requestedRight->getType(); + } + + /** + * {@inheritdoc} + * + * @see \App\Entity\Attribut\LayerAttributInterface::getLayer() + */ + public function getLayer(): string + { + return $this->requestedRight->getLayer(); + } + + /** + * {@inheritdoc} + * + * @see \App\Entity\Attribut\SourceAttributInterface::getSource() + */ + public function getSource(): SourceInterface + { + return $this->requestedRight->getSource(); + } + + /** + * {@inheritdoc} + * + * @see \App\Entity\Attribut\TypeAttributInterface::setType() + */ + public function setType(string $type): void + { + $this->requestedRight->setType($type); + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\RightManagement\RightRequestManagement\RequestedRightInterface::setRequestedSource() + */ + public function setRequestedSource(RequestedSourceInterface $requestedSource) + { + $this->requestedRight->setRequestedSource($requestedSource); + } +} diff --git a/application/symfony/src/Domain/RightManagement/RightRequestManagement/RequestedUserRightFacadeInterface.php b/application/symfony/src/Domain/RightManagement/RightRequestManagement/RequestedUserRightFacadeInterface.php new file mode 100644 index 0000000..a8118ef --- /dev/null +++ b/application/symfony/src/Domain/RightManagement/RightRequestManagement/RequestedUserRightFacadeInterface.php @@ -0,0 +1,12 @@ +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/UserRightInterface.php b/application/symfony/src/Domain/RightManagement/UserRightInterface.php deleted file mode 100644 index 1eeab1d..0000000 --- a/application/symfony/src/Domain/RightManagement/UserRightInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -