powermail icon indicating copy to clipboard operation
powermail copied to clipboard

No access to view in *RenderViewEvents

Open haraldwitt opened this issue 8 months ago • 1 comments

Powermail dispatches 3 events before rendering a view. These are:

  • FormControllerCreateActionBeforeRenderViewEvent
  • FormControllerDisclaimerActionBeforeRenderViewEvent
  • FormControllerOptinConfirmActionBeforeRenderViewEvent

But there is no possibility to influence the view, e. g. via

$view->assign('mySpecialError',`` $mySpecialError);

This is because the $formController itself is only available via a getter (no setter present). And the view is of course protected (inherited from TYPO3\CMS\Extbase\Mvc\Controller\ActionController --> AbstractController --> FormController).

Is it possible to include the view in the parameters of the constructor of the three events and to introduce getView() and setView($view)? Of course the view must be overtaken back in FormController after the event has finished. If desired I could create a pull request for that.

Alternatively it would be helpful to get the $formController per reference (&$formController) in the constructor of the events.

Or should there be an setter for the $formController in general for all Events?

The last and most ugly possibility would be to manipulate the $mail object, where getter and setter are present and the object is overtaken back in FormController after the event has finished.

Update: This "last and ugly" will not function because in the "Powermail Confirm Failed Page" (Resources/Private/Templates/Form/OptinConfirm.html) only {settings} and {labelKey} are available, NO {mail} object. And the view is not accessible. That's just the problem.

Thx for ideas and comments Harald

haraldwitt avatar Jun 12 '24 05:06 haraldwitt