mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Optimized RequestedActionFormBuilderService
This commit is contained in:
@@ -6,11 +6,11 @@ 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\RequestedEntityFormBuilderServiceInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use App\Repository\RepositoryInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -38,9 +38,9 @@ final class ActionService implements ActionServiceInterface
|
||||
private $layerRepositoryFactoryService;
|
||||
|
||||
/**
|
||||
* @var RequestedEntityFormBuilderServiceInterface
|
||||
* @var RequestedActionFormBuilderServiceInterface
|
||||
*/
|
||||
private $entityFormBuilderService;
|
||||
private $requestedActionFormBuilderService;
|
||||
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
@@ -50,13 +50,13 @@ final class ActionService implements ActionServiceInterface
|
||||
/**
|
||||
* @param RequestedActionInterface $requestedAction
|
||||
*/
|
||||
public function __construct(RequestedActionInterface $requestedAction, SecureRequestedRightCheckerInterface $secureRequestedRightChecker, RequestStack $requestStack, LayerRepositoryFactoryServiceInterface $layerRepositoryFactoryService, RequestedEntityFormBuilderServiceInterface $requestedEntityFormBuilderService, EntityManagerInterface $entityManager)
|
||||
public function __construct(RequestedActionInterface $requestedAction, SecureRequestedRightCheckerInterface $secureRequestedRightChecker, RequestStack $requestStack, LayerRepositoryFactoryServiceInterface $layerRepositoryFactoryService, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService, EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->requestedAction = $requestedAction;
|
||||
$this->secureRequestedRightChecker = $secureRequestedRightChecker;
|
||||
$this->requestStack = $requestStack;
|
||||
$this->layerRepositoryFactoryService = $layerRepositoryFactoryService;
|
||||
$this->entityFormBuilderService = $requestedEntityFormBuilderService;
|
||||
$this->requestedActionFormBuilderService = $requestedActionFormBuilderService;
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,7 @@ final class ActionService implements ActionServiceInterface
|
||||
*/
|
||||
public function getForm(): FormBuilderInterface
|
||||
{
|
||||
$requestedEntity = $this->requestedAction->getRequestedEntity();
|
||||
|
||||
return $this->entityFormBuilderService->create($requestedEntity);
|
||||
return $this->requestedActionFormBuilderService->createByService();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,12 +3,12 @@
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
||||
use App\Domain\RequestManagement\Action\RequestedActionInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RequestedEntityFormBuilderService implements RequestedEntityFormBuilderServiceInterface
|
||||
class RequestedActionFormBuilder implements RequestedActionFormBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var FormBuilderInterface
|
||||
@@ -30,14 +30,16 @@ final class RequestedEntityFormBuilderService implements RequestedEntityFormBuil
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param RequestedActionInterface $requestedAction
|
||||
*
|
||||
* @see \App\Domain\FormManagement\EntityFormBuilderServiceInterface::create()
|
||||
* @return FormBuilderInterface
|
||||
*/
|
||||
public function create(RequestedEntityInterface $requestedEntity): FormBuilderInterface
|
||||
public function create(RequestedActionInterface $requestedAction): FormBuilderInterface
|
||||
{
|
||||
$requestedEntity = $requestedAction->getRequestedEntity();
|
||||
$actionType = $requestedAction->getActionType();
|
||||
$origineClass = $requestedEntity->getClass();
|
||||
$class = $this->formClassNameService->getClass($origineClass);
|
||||
$class = $this->formClassNameService->getClass($origineClass, $actionType);
|
||||
if ($requestedEntity->hasIdentity()) {
|
||||
$entity = $requestedEntity->getEntity();
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use App\Domain\RequestManagement\Action\RequestedActionInterface;
|
||||
|
||||
/**
|
||||
* Allowes to create an form which fits to an entity.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedActionFormBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @param RequestedActionInterface $requestedAction
|
||||
*
|
||||
* @return FormBuilderInterface
|
||||
*/
|
||||
public function create(RequestedActionInterface $requestedAction): FormBuilderInterface;
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use App\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RequestedActionFormBuilderService extends RequestedActionFormBuilder implements RequestedActionFormBuilderServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var RequestedActionServiceInterface
|
||||
*/
|
||||
private $requestedActionService;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\FormManagement\RequestedActionFormBuilder::__construct()
|
||||
*/
|
||||
public function __construct(FormBuilderInterface $formBuilder, FormClassNameServiceInterface $formClassNameService, RequestedActionServiceInterface $requestedActionService)
|
||||
{
|
||||
parent::__construct($formBuilder, $formClassNameService);
|
||||
$this->requestedActionService = $requestedActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\FormManagement\RequestedActionFormBuilderServiceInterface::createByRequestedActionService()
|
||||
*/
|
||||
public function createByService(): FormBuilderInterface
|
||||
{
|
||||
return parent::create($this->requestedActionService);
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedActionFormBuilderServiceInterface extends RequestedActionFormBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @return FormBuilderInterface Created by RequestedActionService
|
||||
*/
|
||||
public function createByService(): FormBuilderInterface;
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use App\Domain\RequestManagement\Entity\RequestedEntity;
|
||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
||||
|
||||
/**
|
||||
* Allowes to create an form which fits to an entity.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedEntityFormBuilderServiceInterface
|
||||
{
|
||||
/**
|
||||
* @param RequestedEntityInterface $requestedEntity
|
||||
*
|
||||
* @return FormBuilderInterface
|
||||
*/
|
||||
public function create(RequestedEntityInterface $requestedEntity): FormBuilderInterface;
|
||||
}
|
Reference in New Issue
Block a user