mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
In between commit implementing security layer
This commit is contained in:
parent
bbcf369347
commit
d255623f85
28
application/src/Creator/Factory/AbstractSourceFactory.php
Normal file
28
application/src/Creator/Factory/AbstractSourceFactory.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Creator\Factory;
|
||||
|
||||
use App\Entity\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class AbstractSourceFactory
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
protected function getSourceClassShortName(): string
|
||||
{
|
||||
$reflection = new \ReflectionClass($this->source);
|
||||
|
||||
return $reflection->getShortName();
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Creator\Factory\Facade\Security;
|
||||
|
||||
use App\Structur\Facade\Security\Source\interfaces\SourceFacadeInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SourceFacadeFactory
|
||||
{
|
||||
public function getSourceFacade(): SourceFacadeInterface
|
||||
{
|
||||
$className = $this->getSourceFacadeClassName();
|
||||
|
||||
return new $className();
|
||||
}
|
||||
|
||||
private function getSourceFacadeClassName(): string
|
||||
{
|
||||
return 'App\Structur\Facade\Security\Source\\'.$this->getSourceFacadeClassName().'Facade';
|
||||
}
|
||||
}
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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';
|
||||
|
||||
|
@ -1,27 +1,25 @@
|
||||
<?php
|
||||
namespace App\Structur\Facade\Security;
|
||||
|
||||
namespace App\Structur\Facade\Security\Source;
|
||||
|
||||
use App\Entity\NodeInterface;
|
||||
use App\Entity\SourceInterface;
|
||||
use App\Entity\User;
|
||||
use App\DBAL\Types\RightType;
|
||||
use App\DBAL\Types\LayerType;
|
||||
use App\Structur\Facade\Security\Source\interfaces\SourceFacadeInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
abstract class AbstractSourceFasade implements SourceInterface
|
||||
abstract class AbstractSourceFacade implements SourceFacadeInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var User
|
||||
*/
|
||||
protected static $user;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var SourceInterface
|
||||
*/
|
||||
protected $source;
|
||||
@ -56,7 +54,7 @@ abstract class AbstractSourceFasade implements SourceInterface
|
||||
public function getNode(): NodeInterface
|
||||
{
|
||||
if ($this->isGranted(RightType::READ, LayerType::NODE)) {
|
||||
return $source->getId();
|
||||
return $source->getNode();
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,5 +65,8 @@ abstract class AbstractSourceFasade implements SourceInterface
|
||||
->isGranted(self::$user->getSource()
|
||||
->getNode(), self::$layer, $right);
|
||||
}
|
||||
}
|
||||
|
||||
protected function lazyLoadSourceFacade(SourceInterface $source)
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Structur\Facade\Security\Source;
|
||||
|
||||
use App\Entity\NameSourceInterface;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserSourceInterface;
|
||||
use App\DBAL\Types\RightType;
|
||||
use App\DBAL\Types\LayerType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterface
|
||||
{
|
||||
/**
|
||||
* @var UserSourceInterface
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
public function setNameSource(NameSourceInterface $nameSource): void
|
||||
{
|
||||
throw new \Exception('The name source cant be changed!');
|
||||
}
|
||||
|
||||
public function getNameSource(): NameSourceInterface
|
||||
{
|
||||
if ($this->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
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Structur\Facade\Security\Source\interfaces;
|
||||
|
||||
use App\Entity\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SourceFacadeInterface extends SourceInterface
|
||||
{
|
||||
}
|
Loading…
Reference in New Issue
Block a user