8000 [HttpFoundation] Allow to get all the mime types associated to a format in the Request by GuilhemN · Pull Request #17318 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] Allow to get all the mime types associated to a format in the Request #17318

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
merged 1 commit into from
Jan 14, 2016

Conversation

GuilhemN
Copy link
Contributor
@GuilhemN GuilhemN commented Jan 8, 2016
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT

This PR creates a new method in Request to allow to get all the mime types associated to a format.

This is useful in the case of a format negotiator which needs to convert a list of format to a list of mime types (see the FormatNegotiator of the FOSRestBundle)

*
* @return array The associated mime types
*/
public function getMimeTypes($format)
Copy link
Member

Choose a reason for hiding this comment

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

Why not a static method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 we should also update the other related functions in another PR IMO: setFormat, getMimeType and getFormat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see #17379

@GuilhemN GuilhemN force-pushed the REQUEST branch 4 times, most recently from aa38636 to 0f3af7d Compare January 11, 2016 21:12
$this->assertEquals($mimeTypes, Request::getMimeTypes($format));
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think one more test could be useful, which asserts what getMimeTypes() returns, if the format is not found in Request::$formats.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, added :-)

@nicolas-grekas
Copy link
Member

👍
Status: reviewed

@lsmith77
Copy link
Contributor

👍
status: reviewed

@dunglas
Copy link
Member
dunglas commented Jan 13, 2016

👍

@fabpot
Copy link
Member
fabpot commented Jan 14, 2016

Thank you @Ener-Getick.

@fabpot fabpot merged commit 4618c9f into symfony:master Jan 14, 2016
fabpot added a commit that referenced this pull request Jan 14, 2016
…iated to a format in the Request (Ener-Getick)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[HttpFoundation] Allow to get all the mime types associated to a format in the Request

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT

This PR creates a new method in ``Request`` to allow to get all the mime types associated to a format.

This is useful in the case of a format negotiator which needs to convert a list of format to a list of mime types (see [the ``FormatNegotiator`` of the ``FOSRestBundle``](https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Negotiation/FormatNegotiator.php#L126))

Commits
-------

4618c9f [HttpFoundation] Allow to get all the mime types associated to a format in the Request
@GuilhemN GuilhemN deleted the REQUEST branch January 14, 2016 08:53
@fabpot fabpot mentioned this pull request May 13, 2016
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.

7 participants
0