public function getForm($formId, $formClass, $formType)
    {
        if (isset($this->store[$formClass . ":" . $formType]) && $this->store[$formClass . ":" . $formType] instanceof BaseForm) {
            return $this->store[$formClass . ":" . $formType];
        }

        $formErrorInformation = $this->getSession()->getFormErrorInformation();

        if (isset($formErrorInformation[$formClass.":".$formType])) {
            $formInfo = $formErrorInformation[$formClass.":".$formType];

            if (\is_array($formInfo['data'])) {
                $form = $this->formFactory->createForm(
                    $formId,
                    $formType,
                    $formInfo['data'],
                    [
                        'validation_groups' => $formInfo['validation_groups']
                    ]
                );

                // If the form has errors, perform a validation, to restore the internal error context
                // A controller (as the NewsletterController) may use the parserContext to redisplay a
                // validated (not errored) form. In such cases, another validation may cause unexpected
                // results.
                if (true === $formInfo['hasError']) {
                    try {
                        $this->formValidator->validateForm($form, $formInfo['method']);
                    } catch (\Exception $ex) {
                        // Ignore the exception.
                    }

                    // Manually set the form fields error information, if validateForm() did not the job,
                    // which is the case when the user has been redirected.
                    foreach ($formInfo['field_errors'] as $fieldName => $errors) {
                        /** @var Form $field */
                        $field = $form->getForm()->get($fieldName);

                        if (null !==  $field && \count($field->getErrors()) == 0) {
                            foreach ($errors as $errorData) {
                                $error = new FormError(
                                    $errorData['message'],
                                    $errorData['template'],
                                    $errorData['parameters'],
                                    $errorData['pluralization']
                                );

                                $field->addError($error);
                            }
                        }
                    }
                }

                $form->setError($formInfo['hasError']);

                // Check if error message is empty, as BaseForm::setErrorMessage() always set form error flag to true.
                if (! empty($formInfo['errorMessage'])) {
                    $form->setErrorMessage($formInfo['errorMessage']);
                }

                return $form;
            }
        }

        return null;
    }