mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2026-01-13 10:36:52 +00:00
Optimized RequestedActionFormBuilderService
This commit is contained in:
@@ -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