Skip to content

Commit

Permalink
TASK: Inline ActionController::renderView and document behaviour change
Browse files Browse the repository at this point in the history
The behaviour change of not merging the views full psr response with the previously available legacy response is a combination of the changes

- neos/flow-development-collection#3286
- neos/flow-development-collection#3311
  • Loading branch information
mhsdesign committed Feb 19, 2025
1 parent 9fd6637 commit c64b9b9
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions Classes/Mvc/Controller/ActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
* source code.
*/

use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
use Neos\Error\Messages as Error;
use Neos\Error\Messages\Result;
use Neos\Flow\Annotations as Flow;
use Neos\Error\Messages as Error;
use Neos\Flow\Log\ThrowableStorageInterface;
use Neos\Flow\Log\Utility\LogEnvironment;
use Neos\Flow\Mvc\ActionRequest;
Expand All @@ -36,7 +37,6 @@
use Neos\Flow\Reflection\ReflectionService;
use Neos\Utility\TypeHandling;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -563,7 +563,15 @@ protected function callActionMethod(ActionRequest $request, Arguments $arguments
}

if ($actionResult === null && $this->view instanceof ViewInterface) {
return $this->renderView($httpResponse);
$result = $this->view->render();

if ($result instanceof Response) {
// merging of the $httpResponse (previously $this->response) was previously done to a limited extend via the use of replaceHttpResponse.
// With Flow 9 the returned response will overrule any changes made to $this->response as there is no clear way to merge them.
return $result;
}

return $httpResponse->withBody($result);
}

return $httpResponse->withBody(Utils::streamFor($actionResult));
Expand Down Expand Up @@ -828,20 +836,4 @@ protected function getErrorFlashMessage()
{
return new Error\Error('An error occurred while trying to call %1$s->%2$s()', null, [get_class($this), $this->actionMethodName]);
}

/**
* Renders the view and returns the psr response.
*
* If a stream is returned it will be applied (to the most likely empty response) which was previously available as $this->response.
*/
protected function renderView(ResponseInterface $httpResponse): ResponseInterface
{
$result = $this->view->render();

if ($result instanceof StreamInterface) {
return $httpResponse->withBody($result);
}

return $result;
}
}

0 comments on commit c64b9b9

Please sign in to comment.