Refactored parts of MVCRoutineService to ProcessService

This commit is contained in:
Kevin Frantz 2019-03-27 23:01:45 +01:00
parent 9a95abbaba
commit 4d9813a93d
3 changed files with 121 additions and 78 deletions

View File

@ -3,16 +3,9 @@
namespace Infinito\Domain\MVCManagement;
use FOS\RestBundle\View\View;
use Infinito\Domain\ActionManagement\ActionHandlerServiceInterface;
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
use Infinito\Domain\TemplateManagement\ActionTemplateDataStoreServiceInterface;
use Infinito\Attribut\ActionTypeAttribut;
use Infinito\DBAL\Types\ActionType;
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
use Infinito\Domain\RequestManagement\Action\RequestedActionServiceInterface;
use Infinito\Domain\SecureManagement\SecureRequestedRightCheckerServiceInterface;
use Infinito\Entity\Source\Primitive\Text\TextSource;
use Infinito\Domain\ViewManagement\ViewBuilderInterface;
use Infinito\Domain\ProcessManagement\ProcessServiceInterface;
/**
* @author kevinfrantz
@ -23,60 +16,24 @@ use Infinito\Domain\ViewManagement\ViewBuilderInterface;
final class MVCRoutineService implements MVCRoutineServiceInterface
{
use ActionTypeAttribut;
/**
* @var ActionHandlerServiceInterface
*/
private $actionHandlerService;
/**
* @var TemplateNameServiceInterface
*/
private $templateNameService;
/**
* @var ActionTemplateDataStoreServiceInterface
*/
private $actionTemplateDataStore;
/**
* @var RequestedActionFormBuilderServiceInterface
*/
private $requestedActionFormBuilderService;
/**
* @var RequestedActionServiceInterface
*/
private $requestedActionService;
/**
* @var SecureRequestedRightCheckerServiceInterface
*/
private $secureRequestedRightCheckerService;
/**
* @var ViewBuilderInterface
*/
private $viewBuilder;
/**
* @param ActionHandlerServiceInterface $actionHandlerService
* @param TemplateNameServiceInterface $templateNameService
* @param ActionTemplateDataStoreServiceInterface $actionTemplateDataStore
* @param RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService
* @param RequestedActionServiceInterface $requestedActionService
* @param SecureRequestedRightCheckerServiceInterface $secureRequestedRightCheckerService
* @param ViewBuilderInterface $viewBuilder
* @var ProcessServiceInterface
*/
public function __construct(ActionHandlerServiceInterface $actionHandlerService, TemplateNameServiceInterface $templateNameService, ActionTemplateDataStoreServiceInterface $actionTemplateDataStore, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService, RequestedActionServiceInterface $requestedActionService, SecureRequestedRightCheckerServiceInterface $secureRequestedRightCheckerService, ViewBuilderInterface $viewBuilder)
private $processService;
/**
* @param ViewBuilderInterface $viewBuilder
* @param ProcessServiceInterface $processService
*/
public function __construct(ViewBuilderInterface $viewBuilder, ProcessServiceInterface $processService)
{
$this->actionHandlerService = $actionHandlerService;
$this->templateNameService = $templateNameService;
$this->actionTemplateDataStore = $actionTemplateDataStore;
$this->requestedActionFormBuilderService = $requestedActionFormBuilderService;
$this->requestedActionService = $requestedActionService;
$this->secureRequestedRightCheckerService = $secureRequestedRightCheckerService;
$this->viewBuilder = $viewBuilder;
$this->processService = $processService;
}
/**
@ -87,31 +44,8 @@ final class MVCRoutineService implements MVCRoutineServiceInterface
*/
public function process(): View
{
if (!$this->actionType) {
if ($this->requestedActionService->hasRequestedEntity() && $this->requestedActionService->getRequestedEntity()->hasIdentity()) {
//READ VIEW
// $this->requestedActionService->setActionType(ActionType::READ);
if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
$read = $this->actionHandlerService->handle();
$this->actionTemplateDataStore->setData(ActionType::READ, $read);
}
// $this->requestedActionService->setActionType(ActionType::UPDATE);
//UPDATE VIEW
// if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
// $updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView();
// $this->actionTemplateDataStore->setData(ActionType::UPDATE, $updateForm);
// }
//DELETE VIEW
//EXECUTE VIEW
} else {
//CREATE
$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
$updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView();
$this->actionTemplateDataStore->setData(ActionType::CREATE, $updateForm);
}
$this->processService->process();
return $this->viewBuilder->getView();
}
throw new \Exception('Not implemented yet!');
return $this->viewBuilder->getView();
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace Infinito\Domain\ProcessManagement;
use Infinito\DBAL\Types\ActionType;
use Infinito\Domain\RequestManagement\Action\RequestedActionServiceInterface;
use Infinito\Domain\SecureManagement\SecureRequestedRightCheckerServiceInterface;
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
use Infinito\Domain\ActionManagement\ActionHandlerServiceInterface;
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
use Infinito\Domain\TemplateManagement\ActionTemplateDataStoreServiceInterface;
use Infinito\Entity\Source\Primitive\Text\TextSource;
/**
* @author kevinfrantz
*/
final class ProcessService implements ProcessServiceInterface
{
/**
* @var RequestedActionServiceInterface
*/
private $requestedActionService;
/**
* @var SecureRequestedRightCheckerServiceInterface
*/
private $secureRequestedRightCheckerService;
/**
* @var ActionHandlerServiceInterface
*/
private $actionHandlerService;
/**
* @var TemplateNameServiceInterface
*/
private $templateNameService;
/**
* @var ActionTemplateDataStoreServiceInterface
*/
private $actionTemplateDataStore;
/**
* @var RequestedActionFormBuilderServiceInterface
*/
private $requestedActionFormBuilderService;
/**
* @param ActionHandlerServiceInterface $actionHandlerService
* @param TemplateNameServiceInterface $templateNameService
* @param ActionTemplateDataStoreServiceInterface $actionTemplateDataStore
* @param RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService
* @param RequestedActionServiceInterface $requestedActionService
* @param SecureRequestedRightCheckerServiceInterface $secureRequestedRightCheckerService
*/
public function __construct(ActionHandlerServiceInterface $actionHandlerService, TemplateNameServiceInterface $templateNameService, ActionTemplateDataStoreServiceInterface $actionTemplateDataStore, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService, RequestedActionServiceInterface $requestedActionService, SecureRequestedRightCheckerServiceInterface $secureRequestedRightCheckerService)
{
$this->actionHandlerService = $actionHandlerService;
$this->templateNameService = $templateNameService;
$this->actionTemplateDataStore = $actionTemplateDataStore;
$this->requestedActionFormBuilderService = $requestedActionFormBuilderService;
$this->requestedActionService = $requestedActionService;
$this->secureRequestedRightCheckerService = $secureRequestedRightCheckerService;
}
/**
* {@inheritdoc}
*
* @see \Infinito\Domain\ProcessManagement\ProcessServiceInterface::process()
*/
public function process(): void
{
if ($this->requestedActionService->hasRequestedEntity() && $this->requestedActionService->getRequestedEntity()->hasIdentity()) {
// READ VIEW
// $this->requestedActionService->setActionType(ActionType::READ);
if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
$read = $this->actionHandlerService->handle();
$this->actionTemplateDataStore->setData(ActionType::READ, $read);
}
// $this->requestedActionService->setActionType(ActionType::UPDATE);
// UPDATE VIEW
// if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
// $updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView();
// $this->actionTemplateDataStore->setData(ActionType::UPDATE, $updateForm);
// }
// DELETE VIEW
// EXECUTE VIEW
} else {
// CREATE
$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
$updateForm = $this->requestedActionFormBuilderService->createByService()
->getForm()
->createView();
$this->actionTemplateDataStore->setData(ActionType::CREATE, $updateForm);
}
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace Infinito\Domain\ProcessManagement;
/**
* @author kevinfrantz
*/
interface ProcessServiceInterface
{
public function process(): void;
}