Implemented draft for CRUD management

This commit is contained in:
Kevin Frantz
2019-01-06 20:03:28 +01:00
parent eb55d4ef0b
commit edf0a34e59
16 changed files with 232 additions and 93 deletions

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Domain\SecureCRUDManagement;
/**
* @author kevinfrantz
* @todo Implement!
*/
abstract class AbstractSecureCRUD implements SecureCRUDInterface
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Domain\SecureCRUDManagement\Create;
/**
* @author kevinfrantz
* @todo Implement!
*/
abstract class AbstractSecureCreator implements SecureCreatorInterface
{
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Domain\SecureCRUDManagement\Create;
use App\Domain\SecureCRUDManagement\SecureCRUDInterface;
use App\Entity\EntityInterface;
/**
* @todo Implement!
* @author kevinfrantz
*
*/
interface SecureCreatorInterface extends SecureCRUDInterface
{
/**
* @return EntityInterface The created entity
*/
public function create(): EntityInterface;
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Domain\SecureCRUDManagement\Create;
use App\Entity\EntityInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
use App\Entity\Source\Primitive\Text\TextSource;
/**
* @author kevinfrantz
*
* @todo Implement!
*/
class SecureSourceCreator extends AbstractSecureCreator implements SecureSourceCreatorInterface
{
public function __construct(Request $request, Security $security)
{
}
public function create(): EntityInterface
{
$source = new TextSource();
$source->setText('Hello World!');
return $source;
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Domain\SecureCRUDManagement\Create;
/**
* @author kevinfrantz
* @todo Implement!
*/
interface SecureSourceCreatorInterface extends SecureCreatorInterface
{
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Domain\SecureCRUDManagement;
use App\Entity\Meta\RightInterface;
use App\Domain\SecureCRUDManagement\Create\SecureSourceCreator;
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!
*/
class SecureCRUDFactoryService
{
/**
* @var Request
*/
private $request;
/**
* @var Security
*/
private $security;
public function __construct(RequestStack $requestStack, Security $security)
{
$this->request = $requestStack->getCurrentRequest();
$this->security = $security;
}
/**
* @param RightInterface $requestedRight
*/
public function create(?RightInterface $requestedRight = null)
{
return new SecureSourceCreator($this->request, $this->security);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Domain\SecureCRUDManagement;
/**
* @todo Implement!
* @author kevinfrantz
*
*/
interface SecureCRUDInterface
{
}