Refactored code

This commit is contained in:
Kevin Frantz 2019-04-13 22:48:06 +02:00
parent 504f1e14ee
commit 88ce800478

View File

@ -8,6 +8,7 @@ use Infinito\Domain\ActionManagement\ActionHandlerServiceInterface;
use Infinito\Entity\Source\Primitive\Text\TextSource;
use Infinito\Domain\DataAccessManagement\ActionsResultsDAOServiceInterface;
use Infinito\Domain\ParameterManagement\ValidGetParameterServiceInterface;
use Symfony\Component\Finder\Exception\AccessDeniedException;
/**
* @author kevinfrantz
@ -54,6 +55,26 @@ final class ProcessService implements ProcessServiceInterface
$this->validGetParameterService = $validGetParameterService;
}
/**
* @return mixed|null
*
* @throws AccessDeniedException
*/
private function getResult()
{
if ($this->requestedActionService->hasRequestedEntity() && $this->requestedActionService->getRequestedEntity()->hasIdentity()) {
// READ UPDATE DELETE EXECUTE
if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
return $this->actionHandlerService->handle();
}
throw new AccessDeniedException("The user doesn't have the permission to access this page!");
}
// CREATE
$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
return;
}
/**
* @todo Move
* {@inheritdoc}
@ -62,17 +83,8 @@ final class ProcessService implements ProcessServiceInterface
*/
public function process()
{
$result = null;
$result = $this->getResult();
$actionType = $this->requestedActionService->getActionType();
if ($this->requestedActionService->hasRequestedEntity() && $this->requestedActionService->getRequestedEntity()->hasIdentity()) {
// READ UPDATE DELETE EXECUTE
if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
$result = $this->actionHandlerService->handle();
}
} else {
// CREATE
$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
}
$this->actionsResultsDAOService->setData($actionType, $result);
return $this->actionsResultsDAOService;