mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-17 07:36:03 +02:00
Optimized RequestedEntityFormBuilderService and implemented form classes and logic
This commit is contained in:
@@ -30,11 +30,12 @@ abstract class AbstractAction extends AbstractActionConstructor implements Actio
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\ActionManagement\ActionInterface::execute()
|
||||
*/
|
||||
public function execute()
|
||||
final public function execute()
|
||||
{
|
||||
if ($this->isSecure()) {
|
||||
if ($this->isValidByForm()) {
|
||||
|
@@ -6,7 +6,7 @@ use App\Domain\RequestManagement\Action\RequestedActionInterface;
|
||||
use App\Domain\SecureManagement\SecureRequestedRightCheckerInterface;
|
||||
use App\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Domain\FormManagement\EntityFormBuilderServiceInterface;
|
||||
use App\Domain\FormManagement\RequestedEntityFormBuilderServiceInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use App\Repository\RepositoryInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -38,7 +38,7 @@ final class ActionService implements ActionServiceInterface
|
||||
private $layerRepositoryFactoryService;
|
||||
|
||||
/**
|
||||
* @var
|
||||
* @var RequestedEntityFormBuilderServiceInterface
|
||||
*/
|
||||
private $entityFormBuilderService;
|
||||
|
||||
@@ -50,13 +50,13 @@ final class ActionService implements ActionServiceInterface
|
||||
/**
|
||||
* @param RequestedActionInterface $requestedAction
|
||||
*/
|
||||
public function __construct(RequestedActionInterface $requestedAction, SecureRequestedRightCheckerInterface $secureRequestedRightChecker, RequestStack $requestStack, LayerRepositoryFactoryServiceInterface $layerRepositoryFactoryService, EntityFormBuilderServiceInterface $entityFormBuilderService, EntityManagerInterface $entityManager)
|
||||
public function __construct(RequestedActionInterface $requestedAction, SecureRequestedRightCheckerInterface $secureRequestedRightChecker, RequestStack $requestStack, LayerRepositoryFactoryServiceInterface $layerRepositoryFactoryService, RequestedEntityFormBuilderServiceInterface $requestedEntityFormBuilderService, EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->requestedAction = $requestedAction;
|
||||
$this->secureRequestedRightChecker = $secureRequestedRightChecker;
|
||||
$this->requestStack = $requestStack;
|
||||
$this->layerRepositoryFactoryService = $layerRepositoryFactoryService;
|
||||
$this->entityFormBuilderService = $entityFormBuilderService;
|
||||
$this->entityFormBuilderService = $requestedEntityFormBuilderService;
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ final class ActionService implements ActionServiceInterface
|
||||
*/
|
||||
public function getForm(): FormBuilderInterface
|
||||
{
|
||||
$entity = $this->requestedAction->getRequestedEntity()->getEntity();
|
||||
$requestedEntity = $this->requestedAction->getRequestedEntity();
|
||||
|
||||
return $this->entityFormBuilderService->create($entity);
|
||||
return $this->entityFormBuilderService->create($requestedEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,16 +2,55 @@
|
||||
|
||||
namespace App\Domain\ActionManagement\Create;
|
||||
|
||||
use App\Domain\SourceManagement\SourceClassInformationService;
|
||||
use App\Form\Source\SourceType;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class CreateSourceAction extends AbstractCreateAction
|
||||
{
|
||||
protected function isValidByForm(): bool
|
||||
/**
|
||||
* @var string default class name, when no parameter is defined
|
||||
*/
|
||||
const DEFAULT_CLASS = AbstractSource::class;
|
||||
|
||||
/**
|
||||
* @see SourceClassInformationService
|
||||
*
|
||||
* @var string The source class which should be used
|
||||
*/
|
||||
private $sourceClass;
|
||||
|
||||
private function setSourceClass(): void
|
||||
{
|
||||
$request = $this->actionService->getRequest();
|
||||
$this->sourceClass = $request->get(SourceType::CLASS_PARAMETER_NAME, self::DEFAULT_CLASS);
|
||||
}
|
||||
|
||||
private function prepare(): void
|
||||
{
|
||||
$this->setSourceClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\ActionManagement\AbstractAction::isValidByForm()
|
||||
*/
|
||||
protected function isValidByForm(): bool
|
||||
{
|
||||
$this->actionService->getForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\ActionManagement\AbstractAction::proccess()
|
||||
*/
|
||||
protected function proccess()
|
||||
{
|
||||
$this->prepare();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user