mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2026-04-05 06:42:20 +00:00
In between commit implementing crud draft
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractSecureCRUD implements SecureCRUDInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD;
|
||||
|
||||
use App\Domain\SecureCRUDManagement\AbstractSecureCRUDService as AbstractSecureCRUDServiceParent;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractSecureCRUDService extends AbstractSecureCRUDServiceParent implements SecureCRUDServiceInterface
|
||||
{
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
|
||||
|
||||
use App\Domain\SecureCRUDManagement\CRUD\AbstractSecureCRUD;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractSecureCreate extends AbstractSecureCRUD implements SecureCreateInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
|
||||
|
||||
use App\Domain\SecureCRUDManagement\CRUD\AbstractSecureCRUDService;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractSecureCreateService extends AbstractSecureCRUDService implements SecureCreateServiceInterface
|
||||
{
|
||||
}
|
||||
@@ -3,14 +3,14 @@
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
|
||||
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Domain\SecureCRUDManagement\CRUD\SecureCRUDInterface;
|
||||
use App\Domain\SecureCRUDManagement\CRUD\SecureCRUDServiceInterface;
|
||||
|
||||
/**
|
||||
* @todo Implement!
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureCreateInterface extends SecureCRUDInterface
|
||||
interface SecureCreateServiceInterface extends SecureCRUDServiceInterface
|
||||
{
|
||||
/**
|
||||
* @return EntityInterface The created entity
|
||||
@@ -7,7 +7,7 @@ use App\Entity\EntityInterface;
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureHeredityCreate extends AbstractSecureCreate
|
||||
final class SecureHeredityCreateService extends AbstractSecureCreateService
|
||||
{
|
||||
/**
|
||||
* @todo Implement
|
||||
@@ -7,7 +7,7 @@ use App\Entity\EntityInterface;
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureMemberCreate extends AbstractSecureCreate
|
||||
final class SecureMemberCreateService extends AbstractSecureCreateService
|
||||
{
|
||||
public function create(): EntityInterface
|
||||
{
|
||||
@@ -7,7 +7,7 @@ use App\Entity\EntityInterface;
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureRightCreate extends AbstractSecureCreate
|
||||
final class SecureRightCreateService extends AbstractSecureCreateService
|
||||
{
|
||||
/**
|
||||
* @todo Implement!
|
||||
@@ -10,12 +10,10 @@ use App\Entity\Source\Primitive\Text\TextSource;
|
||||
*
|
||||
* @todo Implement!
|
||||
*/
|
||||
final class SecureSourceCreate extends AbstractSecureCreate
|
||||
final class SecureSourceCreateService extends AbstractSecureCreateService
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureCRUDManagement\CRUD\Create\SecureCreatorInterface::create()
|
||||
* @return EntityInterface
|
||||
*/
|
||||
public function create(): EntityInterface
|
||||
{
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
|
||||
|
||||
use App\Domain\SecureCRUDManagement\CRUD\AbstractSecureCRUDService;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractSecureReadService extends AbstractSecureCRUDService implements SecureReadServiceInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
|
||||
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureLawReadService extends AbstractSecureReadService
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureCRUDManagement\CRUD\Read\SecureReadServiceInterface::read()
|
||||
*/
|
||||
public function read(RightInterface $requestedRight): EntityInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
|
||||
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SecureMemberReadService extends AbstractSecureReadService
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureCRUDManagement\CRUD\Read\SecureReadServiceInterface::read()
|
||||
*/
|
||||
public function read(RightInterface $requestedRight): EntityInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
|
||||
|
||||
use App\Domain\SecureCRUDManagement\CRUD\SecureCRUDServiceInterface;
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureReadServiceInterface extends SecureCRUDServiceInterface
|
||||
{
|
||||
/**
|
||||
* @param RightInterface $requestedRight
|
||||
*
|
||||
* @return EntityInterface
|
||||
*/
|
||||
public function read(RightInterface $requestedRight): EntityInterface;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
|
||||
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureRightReadService extends AbstractSecureReadService
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureCRUDManagement\CRUD\Read\SecureReadServiceInterface::read()
|
||||
*/
|
||||
public function read(RightInterface $requestedRight): EntityInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use App\Domain\SecureManagement\SecureSourceChecker;
|
||||
use App\Exception\SourceAccessDenied;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Domain\SecureCRUDManagement\CRUD\AbstractSecureCRUDService;
|
||||
use App\Entity\EntityInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SecureSourceReadService extends AbstractSecureCRUDService //implements SecureSourceReadServiceInterface
|
||||
{
|
||||
/**
|
||||
* @todo It would be better to specify the type
|
||||
*
|
||||
* @var ObjectRepository
|
||||
*/
|
||||
private $sourceRepository;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $source
|
||||
*
|
||||
* @return RightInterface
|
||||
*/
|
||||
private function getClonedRightWithModifiedSource(SourceInterface $source, RightInterface $requestedRight): RightInterface
|
||||
{
|
||||
$requestedRight = clone $requestedRight;
|
||||
$requestedRight->setSource($source);
|
||||
|
||||
return $requestedRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SourceInterface
|
||||
*/
|
||||
private function loadSource(): SourceInterface
|
||||
{
|
||||
try {
|
||||
return $this->sourceRepository->find($this->requestedRight->getSource()->getId());
|
||||
} catch (\Error $error) {
|
||||
return $this->sourceRepository->findOneBySlug($this->requestedRight->getSource()->getSlug());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\SecureCRUDManagement\AbstractSecureCRUDService::__construct()
|
||||
*/
|
||||
public function __construct(RequestStack $requestStack, Security $security, EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->sourceRepository = $entityManager->getRepository(AbstractSource::class);
|
||||
parent::__construct($requestStack, $security, $entityManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RightInterface $requestedRight
|
||||
*
|
||||
* @return EntityInterface
|
||||
*/
|
||||
public function read(RightInterface $requestedRight): EntityInterface
|
||||
{
|
||||
$source = $this->loadSource();
|
||||
$requestedRight = $this->getClonedRightWithModifiedSource($source, $requestedRight);
|
||||
$secureSourceChecker = new SecureSourceChecker($source);
|
||||
if ($secureSourceChecker->hasPermission($requestedRight)) {
|
||||
return $source;
|
||||
}
|
||||
throw new SourceAccessDenied();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureSourceReadServiceInterface extends SecureReadServiceInterface
|
||||
{
|
||||
}
|
||||
@@ -7,6 +7,6 @@ namespace App\Domain\SecureCRUDManagement\CRUD;
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface SecureCRUDInterface
|
||||
interface SecureCRUDServiceInterface
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user