diff --git a/Classes/Controller/FormController.php b/Classes/Controller/FormController.php index d0dfdab76..c7ecd9aec 100644 --- a/Classes/Controller/FormController.php +++ b/Classes/Controller/FormController.php @@ -78,7 +78,7 @@ public function formAction(): ResponseInterface /** @var FormControllerFormActionEvent $event */ $event = $this->eventDispatcher->dispatch( - GeneralUtility::makeInstance(FormControllerFormActionEvent::class, $form, $this) + GeneralUtility::makeInstance(FormControllerFormActionEvent::class, $form, $this, $this->view) ); $form = $event->getForm(); SessionUtility::saveFormStartInSession($this->settings, $form); diff --git a/Classes/Events/FormControllerFormActionEvent.php b/Classes/Events/FormControllerFormActionEvent.php index aa2e2ce89..61000eb0b 100644 --- a/Classes/Events/FormControllerFormActionEvent.php +++ b/Classes/Events/FormControllerFormActionEvent.php @@ -5,6 +5,7 @@ use In2code\Powermail\Controller\FormController; use In2code\Powermail\Domain\Model\Form; +use TYPO3Fluid\Fluid\View\ViewInterface; final class FormControllerFormActionEvent { @@ -18,14 +19,17 @@ final class FormControllerFormActionEvent */ protected FormController $formController; + protected ViewInterface $view; + /** * @param Form|null $form * @param FormController $formController */ - public function __construct(?Form $form, FormController $formController) + public function __construct(?Form $form, FormController $formController, ViewInterface $view) { $this->form = $form; $this->formController = $formController; + $this->view = $view; } /** @@ -53,4 +57,28 @@ public function getFormController(): FormController { return $this->formController; } + + /** + * Add a variable to the view data collection. + * Can be chained, so $this->view->assign(..., ...)->assign(..., ...); is possible + * + * @param string $key Key of variable + * @param mixed $value Value of object + * @return ViewInterface an instance of $this, to enable chaining + */ + public function assign(string $key, mixed $value) + { + $this->view->assign($key, $value) + } + + /** + * Add multiple variables to the view data collection + * + * @param array $values array in the format array(key1 => value1, key2 => value2) + * @return ViewInterface an instance of $this, to enable chaining + */ + public function assignMultiple(array $values) + { + $this->view->assignMultiple($values); + } }