Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!! FEATURE: http response support in fusion fusion view #4899

Conversation

mhsdesign
Copy link
Member

Based on #4856

With the introduction of Runtime::renderResponse the Fusion Runtime will internally handle the specialities of Neos.Fusion:Http.Message.

Previously when using the Http.Message in plain fusion it would actually render the http response as string, so HTTP/ was part of the content and visible in the dom.

As this logic is now encapsulated in renderResponse, we can easily use it.

Additionally the mentioned pr restricts the functionality of Neos.Neos:Plugin and Neos.Fusion.Form to only work when Runtime::renderResponse is used. So these adjustments are necessary to restore this functionality.

But there is a little catch, the current Fusion FusionView behaves incorrect.
The ViewInterface allows to return string|ActionResponse|ResponseInterface|StreamInterface|\Stringable
But we violate this by returning the raw runtime value instead, which is mixed as it could contain raw arrays or non string-able objects or integers...

My idea is to return ResponseInterface by default and introduce a flag like returnMixed or unsafeRawMode to restore the old "wrong" functionality. By that we empathise that this is not the correct way and it violates the interface. An alternative would be of course to set the flag to true by default which would make it non breaking, but leaves it to the integrators responsibility to set it to false so the mentioned things work.

Ideally people using the FusionView should not notice this change as returning a ResponseInterface is okay by definition and must (is) accounted by the controllers.

As a migration people could either use the propsed unsafe rawmode, or call getContents on the response to get a string.

Also we need a flag for our own as without the flag a lot of "false" test would fail, when we f.x. try to return directly an array or object from the runtime:

Cannot render array into http response body.

But our tests could easily set that flag to render the mixed output directly, in the cases where needed and for (hopefully) most cases we can use the ResponseInterface.

Upgrade instructions

Review instructions

Checklist

  • Code follows the PSR-2 coding style
  • Tests have been created, run and adjusted as needed
  • The PR is created against the lowest maintained branch
  • Reviewer - PR Title is brief but complete and starts with FEATURE|TASK|BUGFIX
  • Reviewer - The first section explains the change briefly for change-logs
  • Reviewer - Breaking Changes are marked with !!! and have upgrade-instructions

+ working legacy layer for manipulating getResponse and accessing getRequest
…o allow setting headers dynamically

Instead, the legacy layer

> $this->runtime->getControllerContext()->getResponse();

should be continued to be used by fusion forms and fusion plugin impl.
Previously the pattern was that the utmost caller of the runtime would unwrap the exception.
To simplify this, as the runtime now has a single entry point, we add this behaviour into the runtime.
This will be discussed separately and not part of the change of the Neos Node `FusionView`
@mhsdesign
Copy link
Member Author

We concluded that it does not make sense to split this up. Will be added to #4856

@mhsdesign mhsdesign closed this Feb 23, 2024
@mhsdesign mhsdesign deleted the feature/httpResponseSupportInFusionFusionView branch April 24, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant