diff --git a/application/symfony/src/Domain/FormManagement/EntityFormBuilderService.php b/application/symfony/src/Domain/FormManagement/EntityFormBuilderService.php new file mode 100644 index 0000000..3922279 --- /dev/null +++ b/application/symfony/src/Domain/FormManagement/EntityFormBuilderService.php @@ -0,0 +1,44 @@ +formBuilder = $formBuilder; + $this->formClassNameService = $formClassNameService; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\FormManagement\EntityFormBuilderServiceInterface::create() + */ + public function create(EntityInterface $entity): FormBuilderInterface + { + $class = $this->formClassNameService->getName($entity); + $form = $this->formBuilder->create($class, $entity); + + return $form; + } +} diff --git a/application/symfony/src/Domain/FormManagement/EntityFormBuilderServiceInterface.php b/application/symfony/src/Domain/FormManagement/EntityFormBuilderServiceInterface.php new file mode 100644 index 0000000..9ceee35 --- /dev/null +++ b/application/symfony/src/Domain/FormManagement/EntityFormBuilderServiceInterface.php @@ -0,0 +1,21 @@ +createMock(FormBuilderInterface::class); + $formBuilder = $this->createMock(FormBuilderInterface::class); + $formBuilder->method('create')->willReturn($expectedResult); + $formClassNameService = $this->createMock(FormClassNameServiceInterface::class); + $formClassNameService->method('getName')->willReturn('dummyNamespace'); + $entityFormBuilderService = new EntityFormBuilderService($formBuilder, $formClassNameService); + $entity = $this->createMock(EntityInterface::class); + $result = $entityFormBuilderService->create($entity); + $this->assertEquals($expectedResult, $result); + } +}