Skip to content

DISCUSSION: How to avoid in fusion access to $this->runtime->getControllerContext()->getResponse()? #4855

@mhsdesign

Description

@mhsdesign

Fusions PluginImplementation

$parentResponse = $this->runtime->getControllerContext()->getResponse();
$pluginResponse = new ActionResponse();
$this->dispatcher->dispatch($this->buildPluginRequest(), $pluginResponse);
// We need to make sure to not merge content up into the parent ActionResponse
// because that would break the Fusion HttpResponse.
$content = $pluginResponse->getContent();
$pluginResponse->setContent('');
$pluginResponse->mergeIntoParentResponse($parentResponse);
return $content;

Fusion RuntimeFormImplementation

https://github.com/neos/fusion-form/blob/642f728976bd205205ce76180b4c701a67adb30c/Classes/Runtime/FusionObjects/RuntimeFormImplementation.php#L172-L174

I guess we would have to replace the controller context with a less ugly but still ugly object and pass that somehow to the view and then to the runtime?

final readonly class ActionMessages
{
     public function __construct(
         public ActionRequest $request,
         public ActionResponse $response
     ) {
     }
}

... or the runtime could return actual an ReponseInterface on the final rendering and could have some internal hacky state to collect the headers?
That would obviously only work for uncached segments to manipulate that global state but still. Basically a hole through space but first level support from fusion. And basically the same as we have now, but less ugliness exposed overall and the view interface doesnt need the controller context for fusion anymore :D

FusionView {
   render(): ReponseInterface
}
FusionRuntime {
   unsafeAdditionalDynamicHeaders: []

   renderResponse() {
      return new Response(render())->withHeaders(unsafeAdditionalDynamicHeaders)
   }
}
SomeFusionObjectImplementation {
   render() {
      // warning this only works if the object is evaluated consistently via mode=uncached.!!!
      runtime.unsafeAdditionalDynamicHeaders['Location'] = "localhost"
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done ✅

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions