2019-03-27 23:01:45 +01:00
|
|
|
<?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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-03-28 13:26:40 +01:00
|
|
|
* @todo Move
|
2019-03-27 23:01:45 +01:00
|
|
|
* {@inheritdoc}
|
|
|
|
*
|
|
|
|
* @see \Infinito\Domain\ProcessManagement\ProcessServiceInterface::process()
|
|
|
|
*/
|
2019-03-29 17:53:06 +01:00
|
|
|
public function process()
|
2019-03-27 23:01:45 +01:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2019-03-29 17:53:06 +01:00
|
|
|
|
|
|
|
return $this->actionTemplateDataStore;
|
2019-03-27 23:01:45 +01:00
|
|
|
}
|
|
|
|
}
|