diff --git a/application/src/Creator/Factory/AbstractSourceFactory.php b/application/src/Creator/Factory/AbstractSourceFactory.php new file mode 100644 index 0000000..f2537e7 --- /dev/null +++ b/application/src/Creator/Factory/AbstractSourceFactory.php @@ -0,0 +1,28 @@ +source = $source; + } + + protected function getSourceClassShortName(): string + { + $reflection = new \ReflectionClass($this->source); + + return $reflection->getShortName(); + } +} diff --git a/application/src/Creator/Factory/Facade/Security/SourceFacadeFactory.php b/application/src/Creator/Factory/Facade/Security/SourceFacadeFactory.php new file mode 100644 index 0000000..c301377 --- /dev/null +++ b/application/src/Creator/Factory/Facade/Security/SourceFacadeFactory.php @@ -0,0 +1,23 @@ +getSourceFacadeClassName(); + + return new $className(); + } + + private function getSourceFacadeClassName(): string + { + return 'App\Structur\Facade\Security\Source\\'.$this->getSourceFacadeClassName().'Facade'; + } +} diff --git a/application/src/Creator/Factory/Form/Source/SourceFormFactory.php b/application/src/Creator/Factory/Form/Source/SourceFormFactory.php index 0be64e9..ae64699 100644 --- a/application/src/Creator/Factory/Form/Source/SourceFormFactory.php +++ b/application/src/Creator/Factory/Form/Source/SourceFormFactory.php @@ -2,25 +2,15 @@ namespace App\Creator\Factory\Form\Source; -use App\Entity\SourceInterface; +use Creator\Factory\AbstractSourceFactory; /** * @author kevinfrantz */ -class SourceFormFactory +final class SourceFormFactory extends AbstractSourceFactory { const FORM_NAMESPACE = 'App\Form\\'; - /** - * @var SourceInterface - */ - private $source; - - public function __construct(SourceInterface $source) - { - $this->source = $source; - } - public function getNamespace(): string { return self::FORM_NAMESPACE.$this->getName(); @@ -28,8 +18,6 @@ class SourceFormFactory protected function getName(): string { - $reflectionClass = new \ReflectionClass($this->source); - - return $reflectionClass->getShortName().'Type'; + return $this->getSourceClassShortName().'Type'; } } diff --git a/application/src/Creator/Factory/Template/Source/SourceTemplateFactory.php b/application/src/Creator/Factory/Template/Source/SourceTemplateFactory.php index 80c2932..19f0cb3 100644 --- a/application/src/Creator/Factory/Template/Source/SourceTemplateFactory.php +++ b/application/src/Creator/Factory/Template/Source/SourceTemplateFactory.php @@ -4,21 +4,17 @@ namespace App\Creator\Factory\Template\Source; use App\Entity\SourceInterface; use Symfony\Component\HttpFoundation\Request; +use Creator\Factory\AbstractSourceFactory; /** * @author kevinfrantz */ -class SourceTemplateFactory +class SourceTemplateFactory extends AbstractSourceFactory { const SOURCE_TEMPLATE_ROOT = 'source'; const VIEW_FOLDER = 'view'; - /** - * @var SourceInterface - */ - protected $source; - /** * @var Request */ @@ -29,7 +25,7 @@ class SourceTemplateFactory */ public function __construct(SourceInterface $source, Request $request) { - $this->source = $source; + parent::__construct($source); $this->request = $request; } @@ -40,9 +36,7 @@ class SourceTemplateFactory protected function generateName(): string { - $reflection = new \ReflectionClass($this->source); - $shortName = $reflection->getShortName(); - $lowerName = strtolower($shortName); + $lowerName = strtolower($this->getSourceClassShortName()); return str_replace('source', '', $lowerName); } diff --git a/application/src/Creator/Factory/Template/Source/SourceTemplateFormFactory.php b/application/src/Creator/Factory/Template/Source/SourceTemplateFormFactory.php index 45bdf90..ddf9e61 100644 --- a/application/src/Creator/Factory/Template/Source/SourceTemplateFormFactory.php +++ b/application/src/Creator/Factory/Template/Source/SourceTemplateFormFactory.php @@ -5,7 +5,7 @@ namespace App\Creator\Factory\Template\Source; /** * @author kevinfrantz */ -class SourceTemplateFormFactory extends SourceTemplateFactory +final class SourceTemplateFormFactory extends SourceTemplateFactory { const FORM_FOLDER = 'form'; diff --git a/application/src/Structur/Facade/Security/AbstractSourceFasade.php b/application/src/Structur/Facade/Security/Source/AbstractSourceFacade.php similarity index 68% rename from application/src/Structur/Facade/Security/AbstractSourceFasade.php rename to application/src/Structur/Facade/Security/Source/AbstractSourceFacade.php index 2a99960..de03e42 100644 --- a/application/src/Structur/Facade/Security/AbstractSourceFasade.php +++ b/application/src/Structur/Facade/Security/Source/AbstractSourceFacade.php @@ -1,27 +1,25 @@ source = $source; @@ -48,24 +46,27 @@ abstract class AbstractSourceFasade implements SourceInterface public function getId(): int { - if($this->isGranted(RightType::READ)){ + if ($this->isGranted(RightType::READ)) { return $source->getId(); } } public function getNode(): NodeInterface { - if($this->isGranted(RightType::READ,LayerType::NODE)){ - return $source->getId(); + if ($this->isGranted(RightType::READ, LayerType::NODE)) { + return $source->getNode(); } } - protected function isGranted(string $right,string $layer): bool + protected function isGranted(string $right, string $layer): bool { return $this->getNode() ->getLaw() ->isGranted(self::$user->getSource() ->getNode(), self::$layer, $right); } -} + protected function lazyLoadSourceFacade(SourceInterface $source) + { + } +} diff --git a/application/src/Structur/Facade/Security/Source/UserSourceFacade.php b/application/src/Structur/Facade/Security/Source/UserSourceFacade.php new file mode 100644 index 0000000..c99dd89 --- /dev/null +++ b/application/src/Structur/Facade/Security/Source/UserSourceFacade.php @@ -0,0 +1,45 @@ +isNameSourceGranted(RightType::READ, LayerType::SOURCE)) { + //FILL! :) + } + } + + private function isNameSourceGranted(string $right, string $layer): bool + { + $nameSource = $this->source->getNameSource(); + $law = $nameSource->getNode()->getLaw(); + $userSourceNode = $this->source->getNode(); + + return $this->isGranted($right, $layer) && $law->isGranted($userSourceNode, $layer, $right); + } + + public function getUser(): User + { + } +} diff --git a/application/src/Structur/Facade/Security/Source/interfaces/SourceFacadeInterface.php b/application/src/Structur/Facade/Security/Source/interfaces/SourceFacadeInterface.php new file mode 100644 index 0000000..63ecf44 --- /dev/null +++ b/application/src/Structur/Facade/Security/Source/interfaces/SourceFacadeInterface.php @@ -0,0 +1,12 @@ +