Optimized RequestedActionFormBuilderService

This commit is contained in:
Kevin Frantz
2019-02-03 16:32:57 +01:00
parent 22c9a92853
commit d3379630c8
9 changed files with 109 additions and 51 deletions

View File

@@ -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();
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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;
}