Skip to content

Commit

Permalink
fix: one instance of FormData per submit
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Oct 25, 2023
1 parent 640736e commit b67dd32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 2 additions & 1 deletion EMS/form-bundle/src/Submission/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ public function submit(FormInterface $form, string $ouuid): array

$responseCollector = new HandleResponseCollector();

$formData = new FormData($formConfig, $form);
foreach ($formConfig->getSubmissions() as $submissionConfig) {
if (!$submissionConfig instanceof SubmissionConfig) {
throw new \RuntimeException('Unexpected not loaded submissions');
}
$handleRequest = new HandleRequest($form, $formConfig, $responseCollector, $submissionConfig);
$handleRequest = new HandleRequest($form, $formConfig, $formData, $responseCollector, $submissionConfig);
$handler = $this->getHandler($handleRequest);

if (null === $handler) {
Expand Down
8 changes: 2 additions & 6 deletions EMS/form-bundle/src/Submission/HandleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@

final class HandleRequest implements HandleRequestInterface
{
private readonly FormData $formData;
private readonly FormConfig $formConfig;

/**
* @param FormInterface<FormInterface> $form
*/
public function __construct(
private readonly FormInterface $form,
FormConfig $formConfig,
private readonly FormConfig $formConfig,
private readonly FormData $formData,
private readonly HandleResponseCollector $responseCollector,
private readonly SubmissionConfig $submissionConfig
) {
$this->formData = new FormData($formConfig, $form);
$this->formConfig = $formConfig;
}

public function addResponse(HandleResponseInterface $response): void
Expand Down

0 comments on commit b67dd32

Please sign in to comment.