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

TASK: Add documentation how work with psr responses in controller #3444

Merged

Conversation

mhsdesign
Copy link
Member

There was some confusion how to replace $this->response when modifying view results.

The suggested pattern now is more explicit instead of providing any form of helper like:

abstract class ResponseInformationHelper
{
    public static function response(Response|StreamInterface $response): Response
    {
        return $response instanceof Response ? $response : new Response(body: $response);
    }
}

Instead this will be written explicitly:

$response = $this->view->render();
if (!$response instanceof Response) {
    $response = new Response(body: $response);
}
return $response
    ->withHeader('My-Header', 'foo');

Also this change inlines ActionController::renderView as the method signature is now really odd and unusable or understandable from the outside. $this->view should instead be used instead like when also assigning variables.

Related changes that lead to the new patterns:

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

The behaviour change of not merging the views full psr response with the previously available legacy response is a combination of the changes

- neos#3286
- neos#3311
@mhsdesign mhsdesign force-pushed the bugfix/provide-alternative-for-this-response branch from 18c8076 to 2ea87da Compare February 19, 2025 11:48
@mhsdesign
Copy link
Member Author

ping @kitsunet ;)

@mhsdesign mhsdesign merged commit 888ec80 into neos:9.0 Feb 20, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants