mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-04-16 10:16:22 +02:00
Optimized implementation of create
This commit is contained in:
parent
6d146c8478
commit
90b14a1ef5
@ -16,9 +16,7 @@ use Infinito\DBAL\Types\ActionType;
|
|||||||
* @see https://symfony.com/blog/new-in-symfony-4-1-prefix-imported-route-names
|
* @see https://symfony.com/blog/new-in-symfony-4-1-prefix-imported-route-names
|
||||||
* @see https://symfony.com/blog/new-in-symfony-4-1-internationalized-routing
|
* @see https://symfony.com/blog/new-in-symfony-4-1-internationalized-routing
|
||||||
* @Route(
|
* @Route(
|
||||||
* {
|
* "/api/rest/{layer}",
|
||||||
* "en":"/api/rest/{layer}/{identity}.{_format}",
|
|
||||||
* },
|
|
||||||
* defaults={
|
* defaults={
|
||||||
* "identity"="",
|
* "identity"="",
|
||||||
* "_format"="json"
|
* "_format"="json"
|
||||||
@ -29,6 +27,25 @@ final class LayerController extends AbstractAPIController
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
|
* ".{_format}",
|
||||||
|
* methods={"GET","POST"}
|
||||||
|
* )
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \Infinito\Controller\API\AbstractAPIController::read()
|
||||||
|
*/
|
||||||
|
public function create(MVCRoutineServiceInterface $mvcRoutineService, RequestedActionServiceInterface $requestedActionService, string $layer, $identity): Response
|
||||||
|
{
|
||||||
|
$requestedActionService->setActionType(ActionType::CREATE);
|
||||||
|
$requestedActionService->setLayer($layer);
|
||||||
|
$view = $mvcRoutineService->process();
|
||||||
|
|
||||||
|
return $this->handleView($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route(
|
||||||
|
* "/{identity}.{_format}",
|
||||||
* methods={"GET"}
|
* methods={"GET"}
|
||||||
* )
|
* )
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -11,6 +11,7 @@ use Infinito\DBAL\Types\ActionType;
|
|||||||
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
|
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
|
||||||
use Infinito\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
use Infinito\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
||||||
use Infinito\Domain\SecureManagement\SecureRequestedRightCheckerServiceInterface;
|
use Infinito\Domain\SecureManagement\SecureRequestedRightCheckerServiceInterface;
|
||||||
|
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -90,7 +91,7 @@ final class MVCRoutineService implements MVCRoutineServiceInterface
|
|||||||
public function process(): View
|
public function process(): View
|
||||||
{
|
{
|
||||||
if (!$this->actionType) {
|
if (!$this->actionType) {
|
||||||
if ($this->requestedActionService->hasRequestedEntity()) {
|
if ($this->requestedActionService->hasRequestedEntity() && $this->requestedActionService->getRequestedEntity()->hasIdentity()) {
|
||||||
//READ
|
//READ
|
||||||
$this->requestedActionService->setActionType(ActionType::READ);
|
$this->requestedActionService->setActionType(ActionType::READ);
|
||||||
if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
|
if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) {
|
||||||
@ -108,6 +109,7 @@ final class MVCRoutineService implements MVCRoutineServiceInterface
|
|||||||
} else {
|
} else {
|
||||||
//CREATE
|
//CREATE
|
||||||
$this->requestedActionService->setActionType(ActionType::CREATE);
|
$this->requestedActionService->setActionType(ActionType::CREATE);
|
||||||
|
$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
|
||||||
$updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView();
|
$updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView();
|
||||||
$this->actionTemplateDataStore->setData(ActionType::CREATE, $updateForm);
|
$this->actionTemplateDataStore->setData(ActionType::CREATE, $updateForm);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ use Infinito\Exception\NotSetException;
|
|||||||
use Infinito\DBAL\Types\ActionType;
|
use Infinito\DBAL\Types\ActionType;
|
||||||
use Infinito\Exception\NotDefinedException;
|
use Infinito\Exception\NotDefinedException;
|
||||||
use Infinito\Exception\NoValidChoiceException;
|
use Infinito\Exception\NoValidChoiceException;
|
||||||
use Infinito\Form\AbstractType;
|
|
||||||
use Infinito\Entity\EntityInterface;
|
use Infinito\Entity\EntityInterface;
|
||||||
use Infinito\Exception\NotCorrectInstanceException;
|
use Infinito\Exception\NotCorrectInstanceException;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
@ -23,7 +22,7 @@ final class ActionTemplateDataStoreService implements ActionTemplateDataStoreSer
|
|||||||
* @var array|string[] Maps the action to an return type
|
* @var array|string[] Maps the action to an return type
|
||||||
*/
|
*/
|
||||||
const ACTION_DATA_MAPPING = [
|
const ACTION_DATA_MAPPING = [
|
||||||
ActionType::CREATE => AbstractType::class,
|
ActionType::CREATE => FormView::class,
|
||||||
ActionType::READ => EntityInterface::class, // Mayber change this to refection later!
|
ActionType::READ => EntityInterface::class, // Mayber change this to refection later!
|
||||||
ActionType::UPDATE => FormView::class,
|
ActionType::UPDATE => FormView::class,
|
||||||
ActionType::DELETE => EntityInterface::class,
|
ActionType::DELETE => EntityInterface::class,
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
{% set icon_class = layer_icon_class_map.getIconClass(layer) %}
|
||||||
|
<i class="{{ icon_class }}"></i>
|
||||||
|
<a href="{{
|
||||||
|
path('infinito_api_rest_layer_create',{'layer':layer,'_format':'html'})}}">
|
||||||
|
{{ layer|trans|capitalize }}
|
||||||
|
</a>
|
@ -1,9 +1,3 @@
|
|||||||
{% set icon_class = layer_icon_class_map.getIconClass(layer) %}
|
|
||||||
<i class="{{ icon_class }}"></i>
|
|
||||||
{# <a href="{{
|
|
||||||
path('infinito_api_rest_layer_read',{'layer':layer,'_format':'html'})}}">
|
|
||||||
#}
|
|
||||||
{{ layer|trans|capitalize }}: {# </a>#}
|
|
||||||
{% if slug is defined and slug%}
|
{% if slug is defined and slug%}
|
||||||
<a
|
<a
|
||||||
href="{{ path('infinito_api_rest_layer_read',{'identity':slug,'layer':layer,'_format':'html'}) }}">
|
href="{{ path('infinito_api_rest_layer_read',{'identity':slug,'layer':layer,'_format':'html'}) }}">
|
@ -2,7 +2,7 @@
|
|||||||
{% extends "frames/default.html.twig" %}
|
{% extends "frames/default.html.twig" %}
|
||||||
{% set layer = requested_action_service.getLayer()%}
|
{% set layer = requested_action_service.getLayer()%}
|
||||||
{% set headline = (layer|trans|capitalize)~': ' %}
|
{% set headline = (layer|trans|capitalize)~': ' %}
|
||||||
{% if requested_action_service.hasRequestedEntity()%}
|
{% if requested_action_service.hasRequestedEntity() and requested_action_service.getRequestedEntity().hasIdentity() %}
|
||||||
{% set entity = requested_action_service.getRequestedEntity().getEntity() %}
|
{% set entity = requested_action_service.getRequestedEntity().getEntity() %}
|
||||||
{% if entity.hasSlug is defined and entity.hasSlug %}
|
{% if entity.hasSlug is defined and entity.hasSlug %}
|
||||||
{% set headline = headline~entity.slug %}
|
{% set headline = headline~entity.slug %}
|
||||||
@ -14,7 +14,10 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>
|
<h1>
|
||||||
{% include "element/link/_layer_link.html.twig" with {'id':entity.getId(),'layer':layer,'slug':((entity.hasSlug() is defined and entity.hasSlug())?entity.getSlug():null)} %}
|
{% include "element/link/_layer_create_link.html.twig" with {'layer':layer} %}
|
||||||
|
{% if entity is defined%}
|
||||||
|
:{% include "element/link/_layer_read_link.html.twig" with {'id':entity.getId(),'layer':layer,'slug':((entity.hasSlug() is defined and entity.hasSlug())?entity.getSlug():null)} %}
|
||||||
|
{% endif %}
|
||||||
</h1>
|
</h1>
|
||||||
{% if action_template_data_store_service.getAllStoredData().count() > 0 %}
|
{% if action_template_data_store_service.getAllStoredData().count() > 0 %}
|
||||||
<div id="accordion">
|
<div id="accordion">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user