mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Implemented draft for update form view
This commit is contained in:
parent
9862bc493c
commit
6dcd9083d4
@ -8,6 +8,8 @@ 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;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -31,6 +33,16 @@ final class MVCRoutineService implements MVCRoutineServiceInterface
|
||||
*/
|
||||
private $actionTemplateDataStore;
|
||||
|
||||
/**
|
||||
* @var RequestedActionFormBuilderServiceInterface
|
||||
*/
|
||||
private $requestedActionFormBuilderService;
|
||||
|
||||
/**
|
||||
* @var RequestedActionServiceInterface
|
||||
*/
|
||||
private $requestedActionService;
|
||||
|
||||
/**
|
||||
* @return View
|
||||
*/
|
||||
@ -46,14 +58,17 @@ final class MVCRoutineService implements MVCRoutineServiceInterface
|
||||
/**
|
||||
* @param ActionHandlerServiceInterface $actionHandlerService
|
||||
*/
|
||||
public function __construct(ActionHandlerServiceInterface $actionHandlerService, TemplateNameServiceInterface $templateNameService, ActionTemplateDataStoreServiceInterface $actionTemplateDataStore)
|
||||
public function __construct(ActionHandlerServiceInterface $actionHandlerService, TemplateNameServiceInterface $templateNameService, ActionTemplateDataStoreServiceInterface $actionTemplateDataStore, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService, RequestedActionServiceInterface $requestedActionService)
|
||||
{
|
||||
$this->actionHandlerService = $actionHandlerService;
|
||||
$this->templateNameService = $templateNameService;
|
||||
$this->actionTemplateDataStore = $actionTemplateDataStore;
|
||||
$this->requestedActionFormBuilderService = $requestedActionFormBuilderService;
|
||||
$this->requestedActionService = $requestedActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Optimize the whole following function. It's just implemented like this for test reasons.
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\MVCManagement\MVCRoutineServiceInterface::process()
|
||||
@ -61,8 +76,14 @@ final class MVCRoutineService implements MVCRoutineServiceInterface
|
||||
public function process(): View
|
||||
{
|
||||
if (!$this->actionType) {
|
||||
$result = $this->actionHandlerService->handle();
|
||||
$this->actionTemplateDataStore->setData(ActionType::READ, $result);
|
||||
//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();
|
||||
|
||||
return $view;
|
||||
|
@ -10,9 +10,9 @@ use Infinito\Exception\NotDefinedException;
|
||||
use Infinito\Exception\NoValidChoiceException;
|
||||
use Infinito\Form\AbstractType;
|
||||
use Infinito\Entity\EntityInterface;
|
||||
use Infinito\Domain\ActionManagement\AbstractAction;
|
||||
use Infinito\Exception\NotCorrectInstanceException;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\Component\Form\FormView;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -25,7 +25,7 @@ final class ActionTemplateDataStoreService implements ActionTemplateDataStoreSer
|
||||
const ACTION_DATA_MAPPING = [
|
||||
ActionType::CREATE => AbstractType::class,
|
||||
ActionType::READ => EntityInterface::class, // Mayber change this to refection later!
|
||||
ActionType::UPDATE => AbstractAction::class,
|
||||
ActionType::UPDATE => FormView::class,
|
||||
ActionType::DELETE => EntityInterface::class,
|
||||
ActionType::EXECUTE => EntityInterface::class, // This is just a dummy value to pass tests. Substitute it!
|
||||
];
|
||||
@ -64,7 +64,7 @@ final class ActionTemplateDataStoreService implements ActionTemplateDataStoreSer
|
||||
if ($data instanceof $instance) {
|
||||
return true;
|
||||
}
|
||||
throw new NotCorrectInstanceException("The intance doesn\'t map to <<$instance>>.");
|
||||
throw new NotCorrectInstanceException('The data class <<'.get_class($data).">> for action type <<$actionType>> doesn't map to instance <<$instance>>.");
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Form\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;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class TextSourceCreateType extends SourceType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Symfony\Component\Form\AbstractType::buildForm()
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
$builder->add('text', TextType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Symfony\Component\Form\AbstractType::configureOptions()
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => TextSource::class,
|
||||
]);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
{{ form(action_template_data_store_service.getData(action)) }}
|
Loading…
Reference in New Issue
Block a user