mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Refactored code and implemented parts of AccessManagement
This commit is contained in:
parent
67d753d9ef
commit
74aad46978
@ -9,6 +9,7 @@ twig:
|
||||
action_icon_class_map: "@Infinito\\Domain\\TwigManagement\\ActionIconClassMap"
|
||||
layer_icon_class_map: "@Infinito\\Domain\\TwigManagement\\LayerIconClassMap"
|
||||
action_template_name_service: "@Infinito\\Domain\\TemplateManagement\\ActionTemplateNameServiceInterface"
|
||||
action_template_data_store_service: "@Infinito\\Domain\\TemplateManagement\\ActionTemplateDataStoreServiceInterface"
|
||||
# @todo rename variable
|
||||
action_template_data_store_service: "@Infinito\\Domain\\DataAccessManagement\\ActionsViewsDAOService"
|
||||
# @todo Remove dom service
|
||||
entity_dom_service: "@Infinito\\Domain\\DomManagement\\EntityDomServiceInterface"
|
@ -3,9 +3,9 @@
|
||||
namespace Infinito\Domain\ActionManagement\Create;
|
||||
|
||||
use Infinito\Domain\SourceManagement\SourceClassInformationService;
|
||||
use Infinito\Form\Source\SourceType;
|
||||
use Infinito\Entity\Source\AbstractSource;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Infinito\Domain\ParameterManagement\Parameter\ClassParameter;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -32,7 +32,7 @@ final class CreateSourceAction extends AbstractCreateAction
|
||||
private function setSourceClass(): void
|
||||
{
|
||||
$request = $this->actionService->getRequest();
|
||||
$this->sourceClass = $request->get(SourceType::CLASS_PARAMETER_NAME, self::DEFAULT_CLASS);
|
||||
$this->sourceClass = $request->get(ClassParameter::getKey(), self::DEFAULT_CLASS);
|
||||
}
|
||||
|
||||
private function setForm(): void
|
||||
|
@ -11,6 +11,7 @@ use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Exception\NotCorrectInstanceException;
|
||||
use Infinito\Entity\EntityInterface;
|
||||
use Infinito\Logic\Result\ResultInterface;
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -22,49 +23,6 @@ final class ActionsResultsDAOService extends AbstractActionsDAO implements Actio
|
||||
*/
|
||||
private $processedData;
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @throws NoValidChoiceException
|
||||
*/
|
||||
private function throwNoValidActionTypeException(string $actionType): void
|
||||
{
|
||||
throw new NoValidChoiceException("The action type <<$actionType>> is not defined and not valid!");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @throws NoValidChoiceException For false a exception is thrown
|
||||
*
|
||||
* @return bool Everytime True
|
||||
*/
|
||||
private function isValidActionType(string $actionType): bool
|
||||
{
|
||||
if (in_array($actionType, ActionType::getValues())) {
|
||||
return true;
|
||||
}
|
||||
$this->throwNoValidActionTypeException($actionType);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function describes which data is expected.
|
||||
*
|
||||
* @param string $actionType
|
||||
* @param mixed $data
|
||||
*
|
||||
* @throws NotCorrectInstanceException For false a exception is thrown
|
||||
*
|
||||
* @return bool Everytime True
|
||||
*/
|
||||
private function validateActionData(string $actionType, $data): bool
|
||||
{
|
||||
if ($this->isValidActionData($actionType)) {
|
||||
return true;
|
||||
}
|
||||
throw new NotCorrectInstanceException('Data <<'.($data).">> for action type <<$actionType>> is not valid!");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
* @param EntityInterface|ResultInterface|null $data
|
||||
@ -84,7 +42,76 @@ final class ActionsResultsDAOService extends AbstractActionsDAO implements Actio
|
||||
case ActionType::EXECUTE:
|
||||
return $data instanceof ResultInterface;
|
||||
}
|
||||
$this->throwNoValidActionTypeException($actionType);
|
||||
throw new NotImplementedException("The ActionType <<$actionType>> is not implemented in <<".__CLASS__.':'.__FUNCTION__.'>>');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @throws NoValidChoiceException
|
||||
*/
|
||||
private function throwNoValidActionTypeException(string $actionType): void
|
||||
{
|
||||
throw new NoValidChoiceException("The action type <<$actionType>> is not defined and not valid!");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isValidActionType(string $actionType): bool
|
||||
{
|
||||
return in_array($actionType, ActionType::getValues());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*/
|
||||
private function validateActionType(string $actionType): void
|
||||
{
|
||||
if (!$this->isValidActionType($actionType)) {
|
||||
$this->throwNoValidActionTypeException($actionType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function describes which data is expected.
|
||||
*
|
||||
* @param string $actionType
|
||||
* @param mixed $data
|
||||
*
|
||||
* @throws NotCorrectInstanceException For false a exception is thrown
|
||||
*/
|
||||
private function validateActionData(string $actionType, $data): void
|
||||
{
|
||||
if (!$this->isValidActionData($actionType, $data)) {
|
||||
throw new NotCorrectInstanceException('Data <<'.gettype($data).(is_object($data) ? ':'.get_class($data) : '').">> is not valid for action type <<$actionType>>!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @throws NotSetException
|
||||
*/
|
||||
private function validateNotSet(string $actionType): void
|
||||
{
|
||||
if ($this->isDataStored($actionType)) {
|
||||
throw new AllreadySetException("Data for <<$actionType>> is allready stored.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @throws NotSetException
|
||||
*/
|
||||
private function validateSet(string $actionType): void
|
||||
{
|
||||
if (!$this->isDataStored($actionType)) {
|
||||
throw new NotSetException("No data for <<$actionType>> is stored.");
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
@ -109,9 +136,9 @@ final class ActionsResultsDAOService extends AbstractActionsDAO implements Actio
|
||||
*/
|
||||
public function setData(string $actionType, $data): void
|
||||
{
|
||||
if ($this->isValidActionType($actionType) && $this->validateActionData($actionType, $data) && $this->isDataStored($actionType)) {
|
||||
throw new AllreadySetException("The data for the action type <<$actionType>> is allready set!");
|
||||
}
|
||||
$this->validateActionType($actionType);
|
||||
$this->validateActionData($actionType, $data);
|
||||
$this->validateNotSet($actionType);
|
||||
$this->processedData->set($actionType, $data);
|
||||
}
|
||||
|
||||
@ -132,9 +159,9 @@ final class ActionsResultsDAOService extends AbstractActionsDAO implements Actio
|
||||
*/
|
||||
public function getData(string $actionType)
|
||||
{
|
||||
if ($this->isValidActionType($actionType) && $this->isDataStored($actionType)) {
|
||||
return $this->processedData->get($actionType);
|
||||
}
|
||||
throw new NotSetException("The data for the action type <<$actionType>> is not set!");
|
||||
$this->validateActionType($actionType);
|
||||
$this->validateSet($actionType);
|
||||
|
||||
return $this->processedData->get($actionType);
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,18 @@ final class ActionsViewsDAOService extends AbstractActionsDAO implements Actions
|
||||
$viewData = $this->getData($key);
|
||||
$storedData->set($key, $viewData);
|
||||
}
|
||||
|
||||
return $storedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement the mapping
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\DataAccessManagement\ActionsDAOInterface::getData()
|
||||
*/
|
||||
public function getData(string $actionType)
|
||||
{
|
||||
return $this->actionsResultsDAO->getData($actionType);
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ final class FormClassNameService implements FormClassNameServiceInterface
|
||||
const ENTITY_BASE_PATH = 'Infinito\\Entity';
|
||||
|
||||
/**
|
||||
* @var string Folder in which the forms are stored
|
||||
* @var string Folder in which the forms for entities are stored
|
||||
*/
|
||||
const FORM_BASE_PATH = 'Infinito\\Form';
|
||||
const FORM_ENTITY_BASE_PATH = 'Infinito\\Form\\Entity';
|
||||
|
||||
/**
|
||||
* @var string Suffix to identifie form classes
|
||||
@ -29,7 +29,7 @@ final class FormClassNameService implements FormClassNameServiceInterface
|
||||
*/
|
||||
public function getClass(string $origineClass, string $type = ''): string
|
||||
{
|
||||
$replaced = str_replace(self::ENTITY_BASE_PATH, self::FORM_BASE_PATH, $origineClass);
|
||||
$replaced = str_replace(self::ENTITY_BASE_PATH, self::FORM_ENTITY_BASE_PATH, $origineClass);
|
||||
$withType = $replaced.ucfirst($type);
|
||||
$withSuffix = $withType.self::SUFFIX;
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\ParameterManagement\Parameter;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class ClassParameter extends AbstractParameter
|
||||
{
|
||||
/**
|
||||
* @todo Implement type validation
|
||||
*/
|
||||
protected $value = null;
|
||||
}
|
@ -8,8 +8,8 @@ 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;
|
||||
use Infinito\Domain\DataAccessManagement\ActionsResultsDAOServiceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -37,9 +37,9 @@ final class ProcessService implements ProcessServiceInterface
|
||||
private $templateNameService;
|
||||
|
||||
/**
|
||||
* @var ActionTemplateDataStoreServiceInterface
|
||||
* @var ActionsResultsDAOServiceInterface
|
||||
*/
|
||||
private $actionTemplateDataStore;
|
||||
private $actionsResultsDAOService;
|
||||
|
||||
/**
|
||||
* @var RequestedActionFormBuilderServiceInterface
|
||||
@ -49,16 +49,16 @@ final class ProcessService implements ProcessServiceInterface
|
||||
/**
|
||||
* @param ActionHandlerServiceInterface $actionHandlerService
|
||||
* @param TemplateNameServiceInterface $templateNameService
|
||||
* @param ActionTemplateDataStoreServiceInterface $actionTemplateDataStore
|
||||
* @param ActionsResultsDAOServiceInterface $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)
|
||||
public function __construct(ActionHandlerServiceInterface $actionHandlerService, TemplateNameServiceInterface $templateNameService, ActionsResultsDAOServiceInterface $actionTemplateDataStore, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService, RequestedActionServiceInterface $requestedActionService, SecureRequestedRightCheckerServiceInterface $secureRequestedRightCheckerService)
|
||||
{
|
||||
$this->actionHandlerService = $actionHandlerService;
|
||||
$this->templateNameService = $templateNameService;
|
||||
$this->actionTemplateDataStore = $actionTemplateDataStore;
|
||||
$this->actionsResultsDAOService = $actionTemplateDataStore;
|
||||
$this->requestedActionFormBuilderService = $requestedActionFormBuilderService;
|
||||
$this->requestedActionService = $requestedActionService;
|
||||
$this->secureRequestedRightCheckerService = $secureRequestedRightCheckerService;
|
||||
@ -77,7 +77,7 @@ final class ProcessService implements ProcessServiceInterface
|
||||
// $this->requestedActionService->setActionType(ActionType::READ);
|
||||
if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
|
||||
$read = $this->actionHandlerService->handle();
|
||||
$this->actionTemplateDataStore->setData(ActionType::READ, $read);
|
||||
$this->actionsResultsDAOService->setData(ActionType::READ, $read);
|
||||
}
|
||||
// $this->requestedActionService->setActionType(ActionType::UPDATE);
|
||||
// UPDATE VIEW
|
||||
@ -88,14 +88,15 @@ final class ProcessService implements ProcessServiceInterface
|
||||
// DELETE VIEW
|
||||
// EXECUTE VIEW
|
||||
} else {
|
||||
// @todo move to view
|
||||
// CREATE
|
||||
$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
|
||||
$updateForm = $this->requestedActionFormBuilderService->createByService()
|
||||
->getForm()
|
||||
->createView();
|
||||
$this->actionTemplateDataStore->setData(ActionType::CREATE, $updateForm);
|
||||
//$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
|
||||
// $updateForm = $this->requestedActionFormBuilderService->createByService()
|
||||
// ->getForm()
|
||||
// ->createView();
|
||||
//$this->actionsResultsDAOService->setData(ActionType::CREATE, $updateForm);
|
||||
}
|
||||
|
||||
return $this->actionTemplateDataStore;
|
||||
return $this->actionsResultsDAOService;
|
||||
}
|
||||
}
|
||||
|
@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\TemplateManagement;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Infinito\Exception\AllreadySetException;
|
||||
use Infinito\Exception\NotSetException;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Exception\NotDefinedException;
|
||||
use Infinito\Exception\NoValidChoiceException;
|
||||
use Infinito\Entity\EntityInterface;
|
||||
use Infinito\Exception\NotCorrectInstanceException;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\Component\Form\FormView;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo rename to ActionViewsDAO and move to DataAccessManagement
|
||||
*/
|
||||
final class ActionTemplateDataStoreService implements ActionTemplateDataStoreServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var array|string[] Maps the action to an return type
|
||||
*/
|
||||
const ACTION_DATA_MAPPING = [
|
||||
ActionType::CREATE => FormView::class,
|
||||
ActionType::READ => EntityInterface::class, // Mayber change this to refection later!
|
||||
ActionType::UPDATE => FormView::class,
|
||||
ActionType::DELETE => EntityInterface::class,
|
||||
ActionType::EXECUTE => EntityInterface::class, // This is just a dummy value to pass tests. Substitute it!
|
||||
];
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
private $actionDataStore;
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @throws NotDefinedException For false a exception is thrown
|
||||
*
|
||||
* @return bool Everytime True
|
||||
*/
|
||||
private function isValidActionType(string $actionType): bool
|
||||
{
|
||||
if (in_array($actionType, ActionType::getValues())) {
|
||||
return true;
|
||||
}
|
||||
throw new NoValidChoiceException("The action type <<$actionType>> is not defined and not valid!");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
* @param mixed $data
|
||||
*
|
||||
* @throws NotCorrectInstanceException For false a exception is thrown
|
||||
*
|
||||
* @return bool Everytime True
|
||||
*/
|
||||
private function isValidActionData(string $actionType, $data): bool
|
||||
{
|
||||
$instance = self::ACTION_DATA_MAPPING[$actionType];
|
||||
if ($data instanceof $instance) {
|
||||
return true;
|
||||
}
|
||||
throw new NotCorrectInstanceException('The data class <<'.get_class($data).">> for action type <<$actionType>> doesn't map to instance <<$instance>>.");
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->actionDataStore = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\TemplateManagement\ActionTemplateDataStoreServiceInterface::setActionTemplateData()
|
||||
*/
|
||||
public function setData(string $actionType, $data): void
|
||||
{
|
||||
if ($this->isValidActionType($actionType) && $this->isValidActionData($actionType, $data) && $this->isDataStored($actionType)) {
|
||||
throw new AllreadySetException("The data for the action type <<$actionType>> is allready set!");
|
||||
}
|
||||
$this->actionDataStore->set($actionType, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\TemplateManagement\ActionTemplateDataStoreServiceInterface::getActionTemplateData()
|
||||
*/
|
||||
public function getData(string $actionType)
|
||||
{
|
||||
if ($this->isValidActionType($actionType) && $this->isDataStored($actionType)) {
|
||||
return $this->actionDataStore->get($actionType);
|
||||
}
|
||||
throw new NotSetException("The data for the action type <<$actionType>> is not set!");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\TemplateManagement\ActionTemplateDataStoreServiceInterface::isActionTemplateDataSet()
|
||||
*/
|
||||
public function isDataStored(string $actionType): bool
|
||||
{
|
||||
return $this->actionDataStore->containsKey($actionType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\TemplateManagement\ActionTemplateDataStoreServiceInterface::getAllData()
|
||||
*/
|
||||
public function getAllStoredData(): Collection
|
||||
{
|
||||
return $this->actionDataStore;
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\TemplateManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* This class offers a temporary data store to pass data from the controller logic to the template.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/Data_store
|
||||
*/
|
||||
interface ActionTemplateDataStoreServiceInterface
|
||||
{
|
||||
/**
|
||||
* @param string $actionType
|
||||
* @param mixed $data The data which a Template needs to be handled
|
||||
*/
|
||||
public function setData(string $actionType, $data): void;
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @return mixed The needed data
|
||||
*/
|
||||
public function getData(string $actionType);
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @return bool True if the data is set
|
||||
*/
|
||||
public function isDataStored(string $actionType): bool;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllStoredData(): Collection;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\Entity;
|
||||
|
||||
use Infinito\Form\AbstractType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractEntityFormType extends AbstractType implements EntityFormTypeInterface
|
||||
{
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\Entity;
|
||||
|
||||
use Infinito\Form\TypeInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface EntityFormTypeInterface extends TypeInterface
|
||||
{
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\Source\Primitive\Text;
|
||||
namespace Infinito\Form\Entity\Source\Primitive\Text;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Infinito\Form\Source\SourceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Form\Entity\Source\SourceFormType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class TextSourceCreateType extends SourceType
|
||||
class TextSourceCreateType extends SourceFormType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\Source\Primitive\Text;
|
||||
namespace Infinito\Form\Entity\Source\Primitive\Text;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\Source;
|
||||
namespace Infinito\Form\Entity\Source;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@ -11,7 +11,7 @@ use Infinito\Attribut\ClassAttributInterface;
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class PureSourceCreateType extends SourceType
|
||||
final class PureSourceCreateType extends SourceFormType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@ -22,7 +22,7 @@ final class PureSourceCreateType extends SourceType
|
||||
{
|
||||
$builder
|
||||
->add(SlugAttributInterface::SLUG_ATTRIBUT_NAME)
|
||||
->add(ClassAttributInterface::CLASS_ATTRIBUT_NAME, SourceType::class, [
|
||||
->add(ClassAttributInterface::CLASS_ATTRIBUT_NAME, SourceFormType::class, [
|
||||
'mapped' => false,
|
||||
]);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\Entity\Source;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Rename!
|
||||
*/
|
||||
interface PureSourceFormTypeInterface
|
||||
{
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\Entity\Source;
|
||||
|
||||
use Infinito\Form\Entity\AbstractEntityFormType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SourceFormType extends AbstractEntityFormType
|
||||
{
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\Source;
|
||||
|
||||
use Infinito\Form\TypeInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Rename!
|
||||
*/
|
||||
interface PureSourceTypeInterface extends TypeInterface
|
||||
{
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\Source;
|
||||
|
||||
use Infinito\Form\AbstractType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class SourceType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const CLASS_PARAMETER_NAME = 'class';
|
||||
}
|
@ -8,9 +8,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class UserSourceType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @todo implement
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Symfony\Component\Form\AbstractType::buildForm()
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('namesource', NameSourceType::class);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
|
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Unit\Domain\TemplateManagement;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Exception\NoValidChoiceException;
|
||||
use Infinito\Exception\NotSetException;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Exception\AllreadySetException;
|
||||
use Infinito\Exception\NotCorrectInstanceException;
|
||||
use Infinito\Domain\DataAccessManagement\ActionsViewsDAOServiceInterface;
|
||||
use Infinito\Domain\DataAccessManagement\ActionsResultsDAOService;
|
||||
use Infinito\Domain\DataAccessManagement\ActionsViewsDAOService;
|
||||
use Infinito\Entity\EntityInterface;
|
||||
use Infinito\Logic\Result\ResultInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class ActionViewsDAOServiceIntegrationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ActionsViewsDAOServiceInterface
|
||||
*/
|
||||
private $actionsViewsDAO;
|
||||
|
||||
/**
|
||||
* @var ActionsResultsDAOService
|
||||
*/
|
||||
private $actionsResultsDAO;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \PHPUnit\Framework\TestCase::setUp()
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->actionsResultsDAO = new ActionsResultsDAOService();
|
||||
$this->actionsViewsDAO = new ActionsViewsDAOService($this->actionsResultsDAO);
|
||||
}
|
||||
|
||||
public function testNotValidChoiceSetException(): void
|
||||
{
|
||||
$this->expectException(NoValidChoiceException::class);
|
||||
$this->actionsResultsDAO->setData('1231232N', ' ');
|
||||
}
|
||||
|
||||
public function testNotCorrectInstanceSetException(): void
|
||||
{
|
||||
$this->expectException(NotCorrectInstanceException::class);
|
||||
$data = new class() {
|
||||
};
|
||||
$this->actionsResultsDAO->setData(ActionType::READ, $data);
|
||||
}
|
||||
|
||||
public function testNotValidChoiceGetException(): void
|
||||
{
|
||||
$this->expectException(NoValidChoiceException::class);
|
||||
$this->actionsViewsDAO->getData('1231232N');
|
||||
}
|
||||
|
||||
public function testNotSetGetException(): void
|
||||
{
|
||||
$this->expectException(NotSetException::class);
|
||||
$this->actionsViewsDAO->getData(ActionType::READ);
|
||||
}
|
||||
|
||||
private function getActionTypeResultDataMock(string $actionType)
|
||||
{
|
||||
switch ($actionType) {
|
||||
case ActionType::READ:
|
||||
case ActionType::CREATE:
|
||||
case ActionType::UPDATE:
|
||||
return $this->createMock(EntityInterface::class);
|
||||
case ActionType::DELETE:
|
||||
return null;
|
||||
case ActionType::EXECUTE:
|
||||
return $this->createMock(ResultInterface::class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo implement test!
|
||||
*
|
||||
* @param string $actionType
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getActionTypeViewDataMock(string $actionType): string
|
||||
{
|
||||
switch (ActionType::class) {
|
||||
case ActionType::READ:
|
||||
case ActionType::CREATE:
|
||||
case ActionType::UPDATE:
|
||||
case ActionType::DELETE:
|
||||
case ActionType::EXECUTE:
|
||||
}
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
foreach (ActionType::getValues() as $actionType) {
|
||||
$this->assertFalse($this->actionsViewsDAO->isDataStored($actionType));
|
||||
$resultData = $this->getActionTypeResultDataMock($actionType);
|
||||
$this->assertNull($this->actionsResultsDAO->setData($actionType, $resultData));
|
||||
$this->assertTrue($this->actionsViewsDAO->isDataStored($actionType));
|
||||
// $viewDataInterface = $this->getActionTypeViewDataMock($actionType);
|
||||
// $this->assertInstanceOf($viewDataInterface, $this->actionsViewsDAO->getData($actionType));
|
||||
}
|
||||
$this->expectException(AllreadySetException::class);
|
||||
$this->assertNull($this->actionsResultsDAO->setData($actionType, $resultData));
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Integration\Domain\AccessManagement;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Exception\NoValidChoiceException;
|
||||
use Infinito\Exception\NotSetException;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Exception\AllreadySetException;
|
||||
use Infinito\Exception\NotCorrectInstanceException;
|
||||
use Infinito\Domain\DataAccessManagement\ActionsResultsDAOService;
|
||||
use Infinito\Entity\EntityInterface;
|
||||
use Infinito\Logic\Result\ResultInterface;
|
||||
use Infinito\Domain\DataAccessManagement\ActionsResultsDAOServiceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class ActionResultsDAOServiceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ActionsResultsDAOServiceInterface
|
||||
*/
|
||||
private $actionsResultsDAO;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \PHPUnit\Framework\TestCase::setUp()
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->actionsResultsDAO = new ActionsResultsDAOService();
|
||||
}
|
||||
|
||||
public function testNotValidChoiceSetException(): void
|
||||
{
|
||||
$this->expectException(NoValidChoiceException::class);
|
||||
$this->actionsResultsDAO->setData('1231232N', ' ');
|
||||
}
|
||||
|
||||
public function testNotCorrectInstanceSetException(): void
|
||||
{
|
||||
$this->expectException(NotCorrectInstanceException::class);
|
||||
$data = new class() {
|
||||
};
|
||||
$this->actionsResultsDAO->setData(ActionType::READ, $data);
|
||||
}
|
||||
|
||||
public function testNotValidChoiceGetException(): void
|
||||
{
|
||||
$this->expectException(NoValidChoiceException::class);
|
||||
$this->actionsResultsDAO->getData('1231232N');
|
||||
}
|
||||
|
||||
public function testNotSetGetException(): void
|
||||
{
|
||||
$this->expectException(NotSetException::class);
|
||||
$this->actionsResultsDAO->getData(ActionType::READ);
|
||||
}
|
||||
|
||||
private function getActionTypeResultDataMock(string $actionType)
|
||||
{
|
||||
switch ($actionType) {
|
||||
case ActionType::READ:
|
||||
case ActionType::CREATE:
|
||||
case ActionType::UPDATE:
|
||||
return $this->createMock(EntityInterface::class);
|
||||
case ActionType::DELETE:
|
||||
return null;
|
||||
case ActionType::EXECUTE:
|
||||
return $this->createMock(ResultInterface::class);
|
||||
}
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
foreach (ActionType::getValues() as $actionType) {
|
||||
$this->assertFalse($this->actionsResultsDAO->isDataStored($actionType));
|
||||
$resultData = $this->getActionTypeResultDataMock($actionType);
|
||||
$this->assertNull($this->actionsResultsDAO->setData($actionType, $resultData));
|
||||
$this->assertTrue($this->actionsResultsDAO->isDataStored($actionType));
|
||||
$this->assertEquals($resultData, $this->actionsResultsDAO->getData($actionType));
|
||||
}
|
||||
$this->expectException(AllreadySetException::class);
|
||||
$this->assertNull($this->actionsResultsDAO->setData($actionType, $resultData));
|
||||
}
|
||||
}
|
@ -17,35 +17,34 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
|
||||
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Infinito\Form\Source\PureSourceTypeInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class CreateSourceActionTest extends TestCase
|
||||
{
|
||||
public function testCreatePureSource(): void
|
||||
{
|
||||
$request = new Request();
|
||||
$request->setMethod(Request::METHOD_POST);
|
||||
$request->query->set(ClassAttributInterface::CLASS_ATTRIBUT_NAME, PureSource::class);
|
||||
$request->request->set(SlugAttributInterface::SLUG_ATTRIBUT_NAME, 'randomname');
|
||||
$requestedActionService = $this->createMock(RequestedActionServiceInterface::class);
|
||||
$secureRequestedRightChecker = $this->createMock(SecureRequestedRightCheckerServiceInterface::class);
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$pureSourceType = $this->createMock(PureSourceTypeInterface::class);
|
||||
$pureSourceType->method('isValid')->willReturn(true);
|
||||
$formBuilderInterface = $this->createMock(FormBuilderInterface::class);
|
||||
$formBuilderInterface->method('getForm')->willReturn($pureSourceType);
|
||||
// $formBuilderInterface->method('isValid')->willReturn(true);
|
||||
$requestedActionFormBuilderService = $this->createMock(RequestedActionFormBuilderServiceInterface::class);
|
||||
$requestedActionFormBuilderService->method('createByService')->willReturn($formBuilderInterface);
|
||||
$requestStack = $this->createMock(RequestStack::class);
|
||||
$requestStack->method('getCurrentRequest')->willReturn($request);
|
||||
$layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
|
||||
$actionService = new ActionService($requestedActionService, $secureRequestedRightChecker, $requestStack, $layerRepositoryFactoryService, $requestedActionFormBuilderService, $entityManager);
|
||||
$createSourceAction = new CreateSourceAction($actionService);
|
||||
$result = $createSourceAction->execute();
|
||||
$this->assertInstanceOf(PureSourceInterface::class, $result);
|
||||
}
|
||||
// public function testCreatePureSource(): void
|
||||
// {
|
||||
// $request = new Request();
|
||||
// $request->setMethod(Request::METHOD_POST);
|
||||
// $request->query->set(ClassAttributInterface::CLASS_ATTRIBUT_NAME, PureSource::class);
|
||||
// $request->request->set(SlugAttributInterface::SLUG_ATTRIBUT_NAME, 'randomname');
|
||||
// $requestedActionService = $this->createMock(RequestedActionServiceInterface::class);
|
||||
// $secureRequestedRightChecker = $this->createMock(SecureRequestedRightCheckerServiceInterface::class);
|
||||
// $entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
// $pureSourceType = $this->createMock(PureSourceTypeInterface::class);
|
||||
// $pureSourceType->method('isValid')->willReturn(true);
|
||||
// $formBuilderInterface = $this->createMock(FormBuilderInterface::class);
|
||||
// $formBuilderInterface->method('getForm')->willReturn($pureSourceType);
|
||||
// // $formBuilderInterface->method('isValid')->willReturn(true);
|
||||
// $requestedActionFormBuilderService = $this->createMock(RequestedActionFormBuilderServiceInterface::class);
|
||||
// $requestedActionFormBuilderService->method('createByService')->willReturn($formBuilderInterface);
|
||||
// $requestStack = $this->createMock(RequestStack::class);
|
||||
// $requestStack->method('getCurrentRequest')->willReturn($request);
|
||||
// $layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
|
||||
// $actionService = new ActionService($requestedActionService, $secureRequestedRightChecker, $requestStack, $layerRepositoryFactoryService, $requestedActionFormBuilderService, $entityManager);
|
||||
// $createSourceAction = new CreateSourceAction($actionService);
|
||||
// $result = $createSourceAction->execute();
|
||||
// $this->assertInstanceOf(PureSourceInterface::class, $result);
|
||||
// }
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class FormClassNameServiceTest extends TestCase
|
||||
$entityClass = PureSource::class;
|
||||
$formNameService = new FormClassNameService();
|
||||
$entityForm = $formNameService->getClass($entityClass);
|
||||
$this->assertEquals('Infinito\\Form\\Source\\PureSourceType', $entityForm);
|
||||
$this->assertEquals('Infinito\\Form\\Entity\\Source\\PureSourceType', $entityForm);
|
||||
}
|
||||
|
||||
public function testWithType(): void
|
||||
@ -25,6 +25,6 @@ class FormClassNameServiceTest extends TestCase
|
||||
$entityClass = PureSource::class;
|
||||
$formNameService = new FormClassNameService();
|
||||
$entityForm = $formNameService->getClass($entityClass, ActionType::CREATE);
|
||||
$this->assertEquals('Infinito\\Form\\Source\\PureSourceCreateType', $entityForm);
|
||||
$this->assertEquals('Infinito\\Form\\Entity\\Source\\PureSourceCreateType', $entityForm);
|
||||
}
|
||||
}
|
||||
|
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Unit\Domain\TemplateManagement;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Domain\TemplateManagement\ActionTemplateDataStoreServiceInterface;
|
||||
use Infinito\Domain\TemplateManagement\ActionTemplateDataStoreService;
|
||||
use Infinito\Exception\NoValidChoiceException;
|
||||
use Infinito\Exception\NotSetException;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Exception\AllreadySetException;
|
||||
use Infinito\Exception\NotCorrectInstanceException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class ActionTemplateDataStoreServiceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ActionTemplateDataStoreServiceInterface
|
||||
*/
|
||||
private $actionTemplateDataStoreService;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \PHPUnit\Framework\TestCase::setUp()
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->actionTemplateDataStoreService = new ActionTemplateDataStoreService();
|
||||
}
|
||||
|
||||
public function testNotValidChoiceSetException(): void
|
||||
{
|
||||
$this->expectException(NoValidChoiceException::class);
|
||||
$this->actionTemplateDataStoreService->setData('1231232N', ' ');
|
||||
}
|
||||
|
||||
public function testNotCorrectInstanceSetException(): void
|
||||
{
|
||||
$this->expectException(NotCorrectInstanceException::class);
|
||||
$data = new class() {
|
||||
};
|
||||
$this->actionTemplateDataStoreService->setData(ActionType::READ, $data);
|
||||
}
|
||||
|
||||
public function testNotValidChoiceGetException(): void
|
||||
{
|
||||
$this->expectException(NoValidChoiceException::class);
|
||||
$this->actionTemplateDataStoreService->getData('1231232N');
|
||||
}
|
||||
|
||||
public function testNotSetGetException(): void
|
||||
{
|
||||
$this->expectException(NotSetException::class);
|
||||
$this->actionTemplateDataStoreService->getData(ActionType::READ);
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
foreach (ActionType::getValues() as $actionType) {
|
||||
$instance = ActionTemplateDataStoreService::ACTION_DATA_MAPPING[$actionType];
|
||||
$data = $this->createMock($instance);
|
||||
$this->assertFalse($this->actionTemplateDataStoreService->isDataStored($actionType));
|
||||
$this->assertNull($this->actionTemplateDataStoreService->setData($actionType, $data));
|
||||
$this->assertTrue($this->actionTemplateDataStoreService->isDataStored($actionType));
|
||||
$this->assertEquals($data, $this->actionTemplateDataStoreService->getData($actionType));
|
||||
}
|
||||
$this->expectException(AllreadySetException::class);
|
||||
$this->assertNull($this->actionTemplateDataStoreService->setData($actionType, $data));
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ namespace tests\Unit\Form\Source;
|
||||
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
use Infinito\Entity\Source\PureSource;
|
||||
use Infinito\Form\Source\PureSourceCreateType;
|
||||
use Infinito\Form\Entity\Source\PureSourceCreateType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
|
Loading…
Reference in New Issue
Block a user