Optimized template draft

This commit is contained in:
Kevin Frantz
2019-02-25 12:50:26 +01:00
parent d0adc9b42a
commit 2cf9e019e8
22 changed files with 208 additions and 178 deletions

View File

@@ -10,6 +10,12 @@ use Infinito\Domain\RequestManagement\Entity\RequestedEntityServiceInterface;
use Infinito\Exception\NotCorrectInstanceException;
/**
* This class is not ready and not tested!
*
* @todo Implement tests!
* @todo finish class!
* @todo refactor class!
*
* @author kevinfrantz
*/
final class EntityDomService implements EntityDomServiceInterface

View File

@@ -10,9 +10,13 @@ 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;
/**
* @author kevinfrantz
*
* @todo Refactor this class
* @todo Test this class
*/
final class MVCRoutineService implements MVCRoutineServiceInterface
{
@@ -48,6 +52,11 @@ final class MVCRoutineService implements MVCRoutineServiceInterface
*/
private $requestedActionService;
/**
* @var SecureRequestedRightCheckerServiceInterface
*/
private $secureRequestedRightCheckerService;
/**
* @return View
*/
@@ -62,13 +71,14 @@ final class MVCRoutineService implements MVCRoutineServiceInterface
/**
* @param ActionHandlerServiceInterface $actionHandlerService
*/
public function __construct(ActionHandlerServiceInterface $actionHandlerService, TemplateNameServiceInterface $templateNameService, ActionTemplateDataStoreServiceInterface $actionTemplateDataStore, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService, RequestedActionServiceInterface $requestedActionService)
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;
}
/**
@@ -80,17 +90,29 @@ final class MVCRoutineService implements MVCRoutineServiceInterface
public function process(): View
{
if (!$this->actionType) {
//UPDATE
$this->requestedActionService->setActionType(ActionType::CREATE);
$updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView();
$this->actionTemplateDataStore->setData(ActionType::UPDATE, $updateForm);
//READ
$this->requestedActionService->setActionType(ActionType::READ);
$read = $this->actionHandlerService->handle();
$this->actionTemplateDataStore->setData(ActionType::READ, $read);
$view = $this->getView();
if ($this->requestedActionService->hasRequestedEntity()) {
//READ
$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
if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
$updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView();
$this->actionTemplateDataStore->setData(ActionType::UPDATE, $updateForm);
}
//DELETE
//EXECUTE
} else {
//CREATE
$this->requestedActionService->setActionType(ActionType::CREATE);
$updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView();
$this->actionTemplateDataStore->setData(ActionType::CREATE, $updateForm);
}
return $view;
return $this->getView();
}
throw new \Exception('Not implemented yet!');
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Infinito\Domain\TwigManagement;
use Infinito\Exception\NotSetException;
use Infinito\DBAL\Types\Meta\Right\LayerType;
/**
* @author kevinfrantz
*/
final class LayerIconClassMap implements LayerIconClassMapInterface
{
/**
* @var array|string[]
*/
const LAYER_ICON_CLASS_MAP = [
LayerType::SOURCE => 'fas fa-tint',
LayerType::LAW => 'fas fa-gavel',
LayerType::RIGHT => 'fas fa-check',
LayerType::HEREDITY => 'fas fa-seedling',
LayerType::MEMBER => 'fas fa-users',
LayerType::CREATOR => 'fas fa-bed',
];
/**
* {@inheritdoc}
*
* @see \Infinito\Domain\TwigManagement\LayerIconClassMapInterface::getIconClass()
*/
public function getIconClass(string $layer): string
{
if (key_exists($layer, self::LAYER_ICON_CLASS_MAP)) {
return self::LAYER_ICON_CLASS_MAP[$layer];
}
throw new NotSetException("The key <<$layer>> is not defined in the map!");
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Infinito\Domain\TwigManagement;
/**
* Maps actions to classes.
*
* @author kevinfrantz
*/
interface LayerIconClassMapInterface
{
/**
* @param string $layer
*
* @return string
*/
public function getIconClass(string $layer): string;
}