Implemented draft for ActionManagement

This commit is contained in:
Kevin Frantz
2019-01-27 15:28:25 +01:00
parent f7242f725e
commit 707df1b951
46 changed files with 686 additions and 831 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Domain\ActionManagement;
use App\Entity\EntityInterface;
use App\Exception\NotSecureException;
use App\Exception\NotValidByFormException;
/**
* @author kevinfrantz
*/
abstract class AbstractAction extends AbstractActionConstructor implements ActionInterface
{
/**
* @return bool
*/
abstract protected function isSecure(): bool;
/**
* @return bool
*/
abstract protected function isValidByForm(): bool;
/**
* Process the routine.
*
* @return EntityInterface|EntityInterface[]|null
*/
abstract protected function proccess();
/**
* @throws \Exception
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\ActionInterface::execute()
*/
public function execute()
{
if ($this->isSecure()) {
if ($this->isValidByForm()) {
return $this->proccess();
}
throw new NotValidByFormException('The requested Entity is not valid!');
}
throw new NotSecureException("You don't have the permission to execute this action!");
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Domain\ActionManagement;
/**
* This class just containes the constructor
* It is used by concrete actions and the factory.
*
* @author kevinfrantz
*/
abstract class AbstractActionConstructor
{
/**
* @var ActionServiceInterface
*/
protected $actionService;
/**
* @param ActionServiceInterface $actionService
*/
final public function __construct(ActionServiceInterface $actionService)
{
$this->actionService = $actionService;
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace App\Domain\ActionManagement;
/**
* @author kevinfrantz
*/
final class ActionFactoryService extends AbstractActionConstructor implements ActionFactoryServiceInterface
{
const BASE_NAMESPACE = 'App\\Domain\\ActionManagement\\';
const CLASS_SUFFIX = 'Action';
/**
* @param string $name
*
* @return string
*/
private function ucfirst(string $name): string
{
return ucfirst(strtolower($name));
}
/**
* @param string $action
* @param string $layer
*
* @return string
*/
private function getClassName(string $action, string $layer = ''): string
{
return $this->ucfirst($action).$this->ucfirst($layer).self::CLASS_SUFFIX;
}
/**
* @param string $layer
* @param string $action
*
* @return string
*/
private function getActionNamespace(string $action, string $layer = ''): string
{
return self::BASE_NAMESPACE.$this->ucfirst($action).'\\'.$this->getClassName($action, $layer);
}
/**
* @return string
*/
private function generateFullClassName(): string
{
$requestedAction = $this->actionService->getRequestedAction();
$action = $requestedAction->getActionType();
$layer = $requestedAction->getLayer();
$class = $this->getActionNamespace($action, $layer);
if (class_exists($class)) {
return $class;
}
$defaultClass = $this->getActionNamespace($action);
return $defaultClass;
}
/**
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\ActionFactoryServiceInterface::create()
*/
public function create(): ActionInterface
{
$class = $this->generateFullClassName();
return new $class($this->actionService);
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Domain\ActionManagement;
/**
* Offers a function to create an action object by the RequestedActionService.
*
* @author kevinfrantz
*/
interface ActionFactoryServiceInterface
{
/**
* @return ActionInterface
*/
public function create(): ActionInterface;
}

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Domain\ActionManagement;
use App\Entity\EntityInterface;
interface ActionInterface
{
/**
* Executes the action.
*
* @return EntityInterface|EntityInterface[]|null
*/
public function execute();
}

View File

@@ -4,12 +4,25 @@ namespace App\Domain\ActionManagement;
use App\Domain\RequestManagement\Action\RequestedActionInterface;
use App\Domain\SecureManagement\SecureRequestedRightCheckerInterface;
use App\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
use Symfony\Component\HttpFoundation\Request;
use App\Domain\FormManagement\EntityFormBuilderServiceInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use App\Repository\RepositoryInterface;
use Symfony\Component\Form\FormBuilderInterface;
use App\Entity\EntityInterface;
use Doctrine\ORM\EntityManagerInterface;
/**
* @author kevinfrantz
*/
final class ActionService implements ActionServiceInterface
{
/**
* @var Request
*/
private $requestStack;
/**
* @var RequestedActionInterface
*/
@@ -20,13 +33,32 @@ final class ActionService implements ActionServiceInterface
*/
private $secureRequestedRightChecker;
/**
* @var LayerRepositoryFactoryServiceInterface
*/
private $layerRepositoryFactoryService;
/**
* @var
*/
private $entityFormBuilderService;
/**
* @var EntityManagerInterface
*/
private $entityManager;
/**
* @param RequestedActionInterface $requestedAction
*/
public function __construct(RequestedActionInterface $requestedAction, SecureRequestedRightCheckerInterface $secureRequestedRightChecker)
public function __construct(RequestedActionInterface $requestedAction, SecureRequestedRightCheckerInterface $secureRequestedRightChecker, RequestStack $requestStack, LayerRepositoryFactoryServiceInterface $layerRepositoryFactoryService, EntityFormBuilderServiceInterface $entityFormBuilderService, EntityManagerInterface $entityManager)
{
$this->requestedAction = $requestedAction;
$this->secureRequestedRightChecker = $secureRequestedRightChecker;
$this->requestStack = $requestStack;
$this->layerRepositoryFactoryService = $layerRepositoryFactoryService;
$this->entityFormBuilderService = $entityFormBuilderService;
$this->entityManager = $entityManager;
}
/**
@@ -48,4 +80,44 @@ final class ActionService implements ActionServiceInterface
{
return $this->secureRequestedRightChecker->check($this->requestedAction);
}
/**
* @return FormBuilderInterface
*/
public function getForm(EntityInterface $entity): FormBuilderInterface
{
$this->entityFormBuilderService->create($entity);
}
/**
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\ActionServiceInterface::getRequest()
*/
public function getRequest(): Request
{
return $this->requestStack->getCurrentRequest();
}
/**
* {@use App\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;inheritDoc}.
*
* @see \App\Domain\ActionManagement\ActionServiceInterface::getRepository()
*/
public function getRepository(): RepositoryInterface
{
$layer = $this->requestedAction->getLayer();
return $this->layerRepositoryFactoryService->getRepository($layer);
}
/**
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\ActionServiceInterface::getEntityManager()
*/
public function getEntityManager(): EntityManagerInterface
{
return $this->entityManager;
}
}

View File

@@ -3,6 +3,11 @@
namespace App\Domain\ActionManagement;
use App\Domain\RequestManagement\Action\RequestedActionInterface;
use Symfony\Component\HttpFoundation\Request;
use App\Repository\RepositoryInterface;
use Symfony\Component\Form\FormBuilderInterface;
use App\Entity\EntityInterface;
use Doctrine\ORM\EntityManagerInterface;
/**
* This interface offers all classes for managing an Action.
@@ -20,4 +25,26 @@ interface ActionServiceInterface
* @return bool true if the action permissions are right
*/
public function isRequestedActionSecure(): bool;
/**
* @return Request
*/
public function getRequest(): Request;
/**
* @return RepositoryInterface
*/
public function getRepository(): RepositoryInterface;
/**
* @param EntityInterface $entity
*
* @return FormBuilderInterface
*/
public function getForm(EntityInterface $entity): FormBuilderInterface;
/**
* @return EntityManagerInterface
*/
public function getEntityManager(): EntityManagerInterface;
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Domain\ActionManagement\Create;
use App\Domain\ActionManagement\AbstractAction;
/**
* @author kevinfrantz
*/
abstract class AbstractCreateAction extends AbstractAction
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Domain\ActionManagement\Create;
/**
* @author kevinfrantz
*/
final class CreateSourceAction extends AbstractCreateAction
{
protected function isSecure(): bool
{
}
protected function isValidByForm(): bool
{
}
protected function proccess()
{
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Domain\ActionManagement\Delete;
use App\Domain\ActionManagement\AbstractAction;
/**
* @author kevinfrantz
* Declare as not final as soon as you need it!
*/
final class DeleteAction extends AbstractAction
{
/**
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\AbstractAction::isSecure()
*/
protected function isSecure(): bool
{
return $this->isSecure();
}
/**
* @todo Implement!
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\AbstractAction::isValidByForm()
*/
protected function isValidByForm(): bool
{
return true;
}
/**
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\AbstractAction::proccess()
*/
protected function proccess()
{
$entityManager = $this->actionService->getEntityManager();
$entity = $this->actionService->getRequestedAction()->getRequestedEntity()->getEntity();
$entityManager->remove($entity);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Domain\ActionManagement\Read;
use App\Domain\ActionManagement\AbstractAction;
/**
* @author kevinfrantz
*/
final class ReadAction extends AbstractAction implements ReadActionInterface
{
/**
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\AbstractAction::isSecure()
*/
protected function isSecure(): bool
{
return $this->actionService->isRequestedActionSecure();
}
/**
* @todo Implement!
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\AbstractAction::isValidByForm()
*/
protected function isValidByForm(): bool
{
return true;
}
/**
* {@inheritdoc}
*
* @see \App\Domain\ActionManagement\AbstractAction::proccess()
*/
protected function proccess()
{
return $this->actionService->getRequestedAction()->getRequestedEntity()->getEntity();
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Domain\ActionManagement\Read;
use App\Domain\ActionManagement\ActionInterface;
/**
* Needed for mocking with PHPUnit!
*
* @author kevinfrantz
*/
interface ReadActionInterface extends ActionInterface
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace App\Domain\ActionManagement\Update;
class UpdateSourceAction
{
}

View File

@@ -1,82 +0,0 @@
<?php
namespace App\Domain\ResponseManagement;
use Symfony\Component\HttpFoundation\Response;
use App\Entity\UserInterface;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Meta\RightInterface;
use Symfony\Component\Security\Core\User\UserInterface as CoreUserInterface;
use FOS\RestBundle\View\ViewHandlerInterface;
use App\Entity\Source\SourceInterface;
use FOS\RestBundle\View\View;
use App\Exception\AllreadyDefinedException;
use App\Domain\SecureCRUDManagement\CRUD\Read\SecureSourceReadService;
/**
* @author kevinfrantz
*
* @todo Implement as a service!
*/
final class SourceRESTResponseManagerService implements SourceRESTResponseManagerServiceInterface
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
/**
* @var RightInterface
*/
private $requestedRight;
/**
* @var SourceInterface
*/
private $loadedSource;
/**
* @var UserInterface
*/
private $user;
public function __construct(CoreUserInterface $user, SecureSourceReadService $secureSourceRead, EntityManagerInterface $entityManager, RightInterface $requestedRight)
{
$this->entityManager = $entityManager;
$this->user = $user;
$this->setRequestedRight($requestedRight);
$this->setLoadedSource();
$this->setView();
}
private function setView(): void
{
$this->view = new View($this->loadedSource, 200);
}
/**
* @param RightInterface $requestedRight
*
* @throws AllreadyDefinedException
*/
private function setRequestedRight(RightInterface $requestedRight): void
{
try {
$requestedRight->getReciever();
throw new AllreadyDefinedException('The reciever is allready defined.');
} catch (\TypeError $error) {
$requestedRight->setReciever($this->user->getSource());
$this->requestedRight = $requestedRight;
}
}
/**
* {@inheritdoc}
*
* @see \App\Domain\ResponseManagement\SourceRESTResponseManagerServiceInterface::getResponse()
*/
public function getResponse(ViewHandlerInterface $viewHandler): Response
{
return $viewHandler->handle($this->view);
}
}

View File

@@ -1,14 +0,0 @@
<?php
namespace App\Domain\ResponseManagement;
use Symfony\Component\HttpFoundation\Response;
use FOS\RestBundle\View\ViewHandlerInterface;
interface SourceRESTResponseManagerServiceInterface
{
/**
* @return Response
*/
public function getResponse(ViewHandlerInterface $viewHandler): Response;
}

View File

@@ -1,40 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\HttpFoundation\RequestStack;
use Doctrine\ORM\EntityManagerInterface;
/**
* @author kevinfrantz
*/
abstract class AbstractSecureCRUDService
{
/**
* @var RequestStack
*/
protected $requestStack;
/**
* @var Security
*/
protected $security;
/**
* @var EntityManagerInterface
*/
protected $entityManager;
/**
* @param RequestStack $requestStack
* @param Security $security
* @param EntityManagerInterface $entityManager
*/
public function __construct(RequestStack $requestStack, Security $security, EntityManagerInterface $entityManager)
{
$this->requestStack = $requestStack;
$this->security = $security;
$this->entityManager = $entityManager;
}
}

View File

@@ -1,12 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\CRUD;
use App\Domain\SecureCRUDManagement\AbstractSecureCRUDService as AbstractSecureCRUDServiceParent;
/**
* @author kevinfrantz
*/
abstract class AbstractSecureCRUDService extends AbstractSecureCRUDServiceParent implements SecureCRUDServiceInterface
{
}

View File

@@ -1,12 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
use App\Domain\SecureCRUDManagement\CRUD\AbstractSecureCRUDService;
/**
* @author kevinfrantz
*/
abstract class AbstractSecureCreateService extends AbstractSecureCRUDService implements SecureCreateServiceInterface
{
}

View File

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

View File

@@ -1,20 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
use App\Entity\EntityInterface;
/**
* @author kevinfrantz
*/
final class SecureHeredityCreateService extends AbstractSecureCreateService
{
/**
* @todo Implement
*
* @return EntityInterface
*/
public function create(): EntityInterface
{
}
}

View File

@@ -1,16 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
use App\Entity\EntityInterface;
/**
* @author kevinfrantz
*/
final class SecureMemberCreateService extends AbstractSecureCreateService
{
public function create(): EntityInterface
{
//todo implement!
}
}

View File

@@ -1,20 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
use App\Entity\EntityInterface;
/**
* @author kevinfrantz
*/
final class SecureRightCreateService extends AbstractSecureCreateService
{
/**
* @todo Implement!
*
* @return EntityInterface
*/
public function create(): EntityInterface
{
}
}

View File

@@ -1,25 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\CRUD\Create;
use App\Entity\EntityInterface;
use App\Entity\Source\Primitive\Text\TextSource;
/**
* @author kevinfrantz
*
* @todo Implement!
*/
final class SecureSourceCreateService extends AbstractSecureCreateService
{
/**
* @return EntityInterface
*/
public function create(): EntityInterface
{
$source = new TextSource();
$source->setText('Hello World!');
return $source;
}
}

View File

@@ -1,12 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
use App\Domain\SecureCRUDManagement\CRUD\AbstractSecureCRUDService;
/**
* @author kevinfrantz
*/
abstract class AbstractSecureReadService extends AbstractSecureCRUDService implements SecureReadServiceInterface
{
}

View File

@@ -1,21 +0,0 @@
<?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
{
}
}

View File

@@ -1,21 +0,0 @@
<?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
{
}
}

View File

@@ -1,20 +0,0 @@
<?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;
}

View File

@@ -1,21 +0,0 @@
<?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
{
}
}

View File

@@ -1,70 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
use App\Entity\Source\SourceInterface;
use App\Entity\Meta\RightInterface;
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;
use App\Repository\Source\SourceRepository;
/**
* @author kevinfrantz
*/
final class SecureSourceReadService extends AbstractSecureCRUDService //implements SecureSourceReadServiceInterface
{
/**
* @todo It would be better to specify the type
*
* @var SourceRepository
*/
private $sourceRepository;
/**
* @param SourceInterface $source
*
* @return RightInterface
*/
private function getClonedRightWithModifiedSource(SourceInterface $source, RightInterface $requestedRight): RightInterface
{
$requestedRight = clone $requestedRight;
$requestedRight->setSource($source);
return $requestedRight;
}
/**
* {@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);
}
/**
* @todo This will not work! Change interface to requested right!
*
* @param RightInterface $requestedRight
*
* @return EntityInterface
*/
public function read(RightInterface $requestedRight): EntityInterface
{
$source = $requestedRight->getSource();
$requestedRight = $this->getClonedRightWithModifiedSource($source, $requestedRight);
$secureSourceChecker = new SecureSourceChecker($source);
if ($secureSourceChecker->hasPermission($requestedRight)) {
return $source;
}
throw new SourceAccessDenied();
}
}

View File

@@ -1,10 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\CRUD\Read;
/**
* @author kevinfrantz
*/
interface SecureSourceReadServiceInterface extends SecureReadServiceInterface
{
}

View File

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

View File

@@ -1,58 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\Factory;
use App\Entity\Meta\RightInterface;
use App\Domain\SecureCRUDManagement\AbstractSecureCRUDService;
use App\Domain\SecureCRUDManagement\CRUD\SecureCRUDServiceInterface;
/**
* @author kevinfrantz
*
* @todo Improve code performance
*/
final class SecureCRUDFactoryService extends AbstractSecureCRUDService implements SecureCRUDFactoryServiceInterface
{
/**
* @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
*/
private function getCRUDNamespace(string $layer, string $crud): string
{
return 'App\\Domain\\SecureCRUDManagement\\CRUD\\'.$this->getCrud($crud).'\\'.$this->getClassName($layer, $crud).'Service';
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SecureCRUDManagement\Factory\SecureCRUDFactoryServiceInterface::create()
*/
public function create(RightInterface $requestedRight): SecureCRUDServiceInterface
{
$namespace = $this->getCRUDNamespace($requestedRight->getLayer(), $requestedRight->getCrud());
return new $namespace($this->requestStack, $this->security, $this->entityManager);
}
}

View File

@@ -1,17 +0,0 @@
<?php
namespace App\Domain\SecureCRUDManagement\Factory;
use App\Entity\Meta\RightInterface;
use App\Domain\SecureCRUDManagement\CRUD\SecureCRUDServiceInterface;
/**
* @author kevinfrantz
*/
interface SecureCRUDFactoryServiceInterface
{
/**
* @return SecureCRUDServiceInterface
*/
public function create(RightInterface $requestedRight): SecureCRUDServiceInterface;
}

View File

@@ -1,43 +0,0 @@
<?php
namespace App\Domain\ViewManagement;
use FOS\RestBundle\View\View;
use App\Domain\RequestManagement\RequestedUser;
use App\Domain\SecureCRUDManagement\Factory\SecureCRUDFactoryService;
use App\Domain\SecureCRUDManagement\Factory\SecureCRUDFactoryServiceInterface;
/**
* @author kevinfrantz
*/
class AbstractViewBuilder implements ViewBuilderInterface
{
/**
* @var View
*/
protected $view;
/**
* @var SecureCRUDFactoryServiceInterface
*/
protected $secureCrudFactoryService;
/**
* @param RequestedUser $requestedUserRight
* @param SecureCRUDFactoryService $secureCrudFactoryService
*/
public function __construct(RequestedUser $requestedUserRight, SecureCRUDFactoryService $secureCrudFactoryService)
{
$this->view = new View();
$this->requestedUserRight = $requestedUserRight;
$this->secureCrudFactoryService = $secureCrudFactoryService;
}
/**
* @return View
*/
public function getView(): View
{
$this->secureCrudFactoryService->create($requestedRight);
}
}

View File

@@ -0,0 +1,60 @@
<?php
namespace App\Domain\ViewManagement;
use FOS\RestBundle\View\View;
use App\Domain\SecureCRUDManagement\Factory\SecureCRUDFactoryService;
use App\Domain\SecureCRUDManagement\Factory\SecureCRUDFactoryServiceInterface;
use App\Domain\RequestManagement\User\RequestedUserInterface;
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
/**
* @author kevinfrantz
*/
class ViewBuilder implements ViewBuilderInterface
{
/**
* @var View
*/
protected $view;
/**
* @var SecureCRUDFactoryServiceInterface
*/
protected $secureCrudFactoryService;
/**
* @var RequestedEntityInterface
*/
protected $requestedEntity;
/**
* @var RequestedUserInterface
*/
protected $requestedUser;
/**
* @param RequestedUserInterface $requestedUserRight
* @param SecureCRUDFactoryService $secureCrudFactoryService
*/
public function __construct(RequestedUserInterface $requestedUserRight, SecureCRUDFactoryService $secureCrudFactoryService, RequestedEntityInterface $requestedEntity)
{
$this->view = new View();
$this->requestedUser = $requestedUserRight;
$this->secureCrudFactoryService = $secureCrudFactoryService;
$this->requestedEntity = $requestedEntity;
}
private function process()
{
$secureCrudService = $this->secureCrudFactoryService->create($this->requestedUser);
$entity = $secureCrudService->process($this->requestedEntity);
}
/**
* @return View
*/
public function getView(): View
{
}
}