Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Allow set return content type #296

Merged
merged 9 commits into from Aug 7, 2020
Merged

Conversation

romkatsu
Copy link
Member

@romkatsu romkatsu commented Aug 6, 2020

Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Fixed issues Allow set return content type

A single render is needed when the output should be the same regardless of the request.

@romkatsu romkatsu requested a review from a team August 6, 2020 18:12
@romkatsu romkatsu added the status:code review The pull request needs review. label Aug 6, 2020
@samdark
Copy link
Member

samdark commented Aug 7, 2020

  1. What's the use-case?
  2. Can it be done as ->withoutRenderers()->withRenderer()?

@romkatsu
Copy link
Member Author

romkatsu commented Aug 7, 2020

1. What's the use-case?

2. Can it be done as ->withoutRenderers()->withRenderer()?
  1. rest api - regardless of the request you need to return errors in json format
  2. No. These methods only add-remove the Renderers. The desired render is taken from the accept header
$contentType = $this->getContentType($request);
$renderer = $this->getRenderer(strtolower($contentType));

@samdark samdark merged commit bae487b into yiisoft:master Aug 7, 2020
@samdark
Copy link
Member

samdark commented Aug 7, 2020

👍

if ($this->contentType !== null) {
return $this->contentType;
}

try {
foreach (HeaderHelper::getSortedAcceptTypes($request->getHeader('accept')) as $header) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
foreach (HeaderHelper::getSortedAcceptTypes($request->getHeader('accept')) as $header) {
foreach (HeaderHelper::getSortedAcceptTypes($request->getHeader(Header::ACCEPT)) as $header) {

devanych pushed a commit that referenced this pull request Feb 1, 2021
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
devanych pushed a commit that referenced this pull request Feb 1, 2021
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
devanych pushed a commit that referenced this pull request Feb 1, 2021
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
devanych pushed a commit that referenced this pull request Feb 1, 2021
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
devanych pushed a commit that referenced this pull request Feb 1, 2021
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
devanych pushed a commit that referenced this pull request Feb 1, 2021
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
devanych pushed a commit that referenced this pull request Feb 1, 2021
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
devanych pushed a commit that referenced this pull request Feb 1, 2021
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:code review The pull request needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants