mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2026-04-05 06:42:20 +00:00
Optimized SecureCRUDManagement Draft
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\Factory;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Implement!
|
||||
* @todo substitute through child classes!
|
||||
*/
|
||||
abstract class AbstractSecureCRUDFactoryService implements SecureCRUDFactoryServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var Security
|
||||
*/
|
||||
protected $security;
|
||||
|
||||
/**
|
||||
* @param string $crud
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getCrud(string $crud): string
|
||||
{
|
||||
return ucfirst(strtolower($crud));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $layer
|
||||
* @param string $crud
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getClassName(string $layer, string $crud): string
|
||||
{
|
||||
return 'Secure'.ucfirst(strtolower($layer)).$this->getCrud($crud);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $layer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getCRUDNamespace(string $layer, string $crud): string
|
||||
{
|
||||
return 'App\\Domain\\SecureCRUDManagement\\CRUD\\'.$this->getCrud($crud).'\\'.$this->getClassName($layer, $crud);
|
||||
}
|
||||
|
||||
public function __construct(RequestStack $requestStack, Security $security)
|
||||
{
|
||||
$this->request = $requestStack->getCurrentRequest();
|
||||
$this->security = $security;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\Factory;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Domain\SecureCRUDManagement\CRUD\Create\SecureCreatorInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureCRUDFactoryServiceInterface
|
||||
{
|
||||
/**
|
||||
* @return SecureCreatorInterface
|
||||
*/
|
||||
public function create(RightInterface $requestedRight): SecureCreatorInterface;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\Factory;
|
||||
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\DBAL\Types\Meta\Right\LayerType;
|
||||
use App\Domain\SecureCRUDManagement\CRUD\Create\SecureCreatorInterface;
|
||||
use App\Domain\SecureCRUDManagement\CRUD\Create\SecureSourceCreator;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Implement!
|
||||
*/
|
||||
final class SecureCreatorFactoryService extends AbstractSecureCRUDFactoryService
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureCRUDManagement\Factory\SecureCRUDFactoryServiceInterface::create()
|
||||
*/
|
||||
public function create(RightInterface $requestedRight): SecureCreatorInterface
|
||||
{
|
||||
switch ($requestedRight->getLayer()) {
|
||||
case LayerType::SOURCE:
|
||||
return new SecureSourceCreator($this->request, $this->security);
|
||||
case LayerType::MEMBER:
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\Factory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureCreatorFactoryServiceInterface extends SecureCRUDFactoryServiceInterface
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user