-
-
Notifications
You must be signed in to change notification settings - Fork 190
!!! FEATURE: ViewInterface returns PSR StreamInterface
#3286
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
Merged
mhsdesign
merged 10 commits into
neos:9.0
from
mhsdesign:feature/viewInterfaceWithoutControllerContext
Apr 24, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
93ba58d
WIP: Make ViewInterface independent of controller context
mhsdesign 3afca62
WIP: Introduce ActionMessages tuple to replace controller context
mhsdesign ac8cfc7
Revert "WIP: Introduce ActionMessages tuple to replace controller con…
mhsdesign d91c6a2
!!! TASK JsonView returns ResponseInterface directly
mhsdesign 227670a
Fix ci
mhsdesign 1ae08a8
!!! TASK: `ViewInterface::canRender`
mhsdesign cc8f3a9
!!! TASK: Strict render type for views `ResponseInterface|StreamInter…
mhsdesign 9bb5133
TASK: Refactor stream sending
mhsdesign ff51048
TASK: Update composer.json build
mhsdesign 524f61e
!!! TASK: Add strict types to `ViewInterface`
mhsdesign File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,19 +12,23 @@ | |
| * source code. | ||
| */ | ||
|
|
||
| use GuzzleHttp\Psr7\Response; | ||
| use Neos\Flow\Annotations as Flow; | ||
| use Neos\Flow\Mvc\Controller\ControllerContext; | ||
| use Neos\Flow\Persistence\PersistenceManagerInterface; | ||
| use Neos\Http\Factories\StreamFactoryTrait; | ||
| use Neos\Utility\ObjectAccess; | ||
| use Neos\Utility\TypeHandling; | ||
| use Psr\Http\Message\ResponseInterface; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deprecate
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we deprecated the json view ... what is our answer to code like this? :O /**
* @var array
*/
protected $viewFormatToObjectNameMap = [
'html' => FusionView::class,
'json' => JsonView::class,
];do we need a new simple json view? :P cc @kitsunet |
||
|
|
||
| /** | ||
| * A JSON view | ||
| * | ||
| * @api | ||
| * @deprecated please use json_encode instead | ||
| */ | ||
| class JsonView extends AbstractView | ||
| { | ||
| use StreamFactoryTrait; | ||
|
|
||
| /** | ||
| * Supported options | ||
| * @var array | ||
|
|
@@ -50,11 +54,6 @@ class JsonView extends AbstractView | |
| */ | ||
| const EXPOSE_CLASSNAME_UNQUALIFIED = 2; | ||
|
|
||
| /** | ||
| * @var ControllerContext | ||
| */ | ||
| protected $controllerContext; | ||
|
|
||
| /** | ||
| * Only variables whose name is contained in this array will be rendered | ||
| * | ||
|
|
@@ -195,15 +194,17 @@ public function setConfiguration(array $configuration) | |
| * array represantion using a YAML view configuration and JSON encodes | ||
| * the result. | ||
| * | ||
| * @return string The JSON encoded variables | ||
| * @return ResponseInterface The JSON encoded variables | ||
| * @api | ||
| */ | ||
| public function render() | ||
| public function render(): ResponseInterface | ||
| { | ||
| $this->controllerContext->getResponse()->setContentType('application/json'); | ||
| $response = new Response(); | ||
| $response = $response->withHeader('Content-Type', 'application/json'); | ||
| $propertiesToRender = $this->renderArray(); | ||
| $options = $this->getOption('jsonEncodingOptions'); | ||
| return json_encode($propertiesToRender, JSON_THROW_ON_ERROR | $options); | ||
| $value = json_encode($propertiesToRender, JSON_THROW_ON_ERROR | $options); | ||
| return $response->withBody($this->createStream($value)); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.