mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 06:27:24 +01:00
Optimized SecureCRUDManagement Draft
This commit is contained in:
parent
6b29c5a577
commit
51667ee381
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
|
||||
|
||||
use App\Domain\SecureCRUDManagement\AbstractSecureCRUD;
|
||||
use App\Domain\SecureCRUDManagement\CRUD\AbstractSecureCRUD;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
|
||||
|
||||
use App\Domain\SecureCRUDManagement\SecureCRUDInterface;
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Domain\SecureCRUDManagement\CRUD\SecureCRUDInterface;
|
||||
|
||||
/**
|
||||
* @todo Implement!
|
||||
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
|
||||
|
||||
use App\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureHeredityCreator extends AbstractSecureCreator
|
||||
{
|
||||
/**
|
||||
* @todo Implement
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureCRUDManagement\CRUD\Create\SecureCreatorInterface::create()
|
||||
*/
|
||||
public function create(): EntityInterface
|
||||
{
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
|
||||
|
||||
use App\Domain\SecureCRUDManagement\Create\AbstractSecureCreator;
|
||||
use App\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
@ -10,11 +9,6 @@ use App\Entity\EntityInterface;
|
||||
*/
|
||||
final class SecureMemberCreator extends AbstractSecureCreator
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureCRUDManagement\Create\SecureCreatorInterface::create()
|
||||
*/
|
||||
public function create(): EntityInterface
|
||||
{
|
||||
//todo implement!
|
||||
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
|
||||
|
||||
use App\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureRightCreator extends AbstractSecureCreator
|
||||
{
|
||||
/**
|
||||
* @todo Implement!
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureCRUDManagement\CRUD\Create\SecureCreatorInterface::create()
|
||||
*/
|
||||
public function create(): EntityInterface
|
||||
{
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ abstract class AbstractSecureCRUDFactoryService implements SecureCRUDFactoryServ
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getClassName(string $layer, string $crud): string
|
||||
protected function getClassName(string $layer, string $crud): string
|
||||
{
|
||||
return 'Secure'.ucfirst(strtolower($layer)).$this->getCrud($crud);
|
||||
}
|
||||
|
@ -3,9 +3,8 @@
|
||||
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;
|
||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -14,6 +13,19 @@ use App\Domain\SecureCRUDManagement\CRUD\Create\SecureSourceCreator;
|
||||
*/
|
||||
final class SecureCreatorFactoryService extends AbstractSecureCRUDFactoryService
|
||||
{
|
||||
const CRUD_TYPE = CRUDType::CREATE;
|
||||
|
||||
/**
|
||||
* @param string $layer
|
||||
* @param string $crud
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getClassName(string $layer, string $crud): string
|
||||
{
|
||||
return 'Secure'.ucfirst(strtolower($layer)).'Creator';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
@ -21,10 +33,8 @@ final class SecureCreatorFactoryService extends AbstractSecureCRUDFactoryService
|
||||
*/
|
||||
public function create(RightInterface $requestedRight): SecureCreatorInterface
|
||||
{
|
||||
switch ($requestedRight->getLayer()) {
|
||||
case LayerType::SOURCE:
|
||||
return new SecureSourceCreator($this->request, $this->security);
|
||||
case LayerType::MEMBER:
|
||||
}
|
||||
$namespace = $this->getCRUDNamespace($requestedRight->getLayer(), self::CRUD_TYPE);
|
||||
|
||||
return new $namespace($this->request, $this->security);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Unit\Domain\SecureCRUDManagement\Factory;
|
||||
|
||||
use App\Domain\SecureCRUDManagement\Factory\SecureCreatorFactoryServiceInterface;
|
||||
use App\Domain\SecureCRUDManagement\Factory\SecureCreatorFactoryService;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use App\DBAL\Types\Meta\Right\LayerType;
|
||||
use App\Entity\Meta\Right;
|
||||
use App\Domain\SecureCRUDManagement\CRUD\Create\SecureCreatorInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SecureCreatorFactoryServiceTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @var SecureCreatorFactoryServiceInterface
|
||||
*/
|
||||
private $secureCreatorFactoryService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$requestStack = self::$container->get('request_stack');
|
||||
$security = new Security(self::$kernel->getContainer());
|
||||
$this->secureCreatorFactoryService = new SecureCreatorFactoryService($requestStack, $security);
|
||||
}
|
||||
|
||||
public function testCreate(): void
|
||||
{
|
||||
$excludedTypes = [
|
||||
LayerType::LAW,
|
||||
];
|
||||
foreach (LayerType::getChoices() as $layer) {
|
||||
if (!in_array($layer, $excludedTypes)) {
|
||||
$requestedRight = new Right();
|
||||
$requestedRight->setLayer($layer);
|
||||
$secureCreator = $this->secureCreatorFactoryService->create($requestedRight);
|
||||
$this->assertInstanceOf(SecureCreatorInterface::class, $secureCreator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user