Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fbca6db

Browse files
committed
minor #9898 [HttpFoundation] Add info for getAcceptableFormats() method (AndreiIgna)
This PR was squashed before being merged into the master branch (closes #9898). Discussion ---------- [HttpFoundation] Add info for getAcceptableFormats() method Adds info for `Request::getAcceptableFormats()` Should it add more info on docs page? Ex: `Request::getAcceptableContentTypes` returns the accepted content types which can be `text/html`, `application/json`, etc. `Request::getAcceptableFormats` processes that and returns the formats based on those content types `html`, `json` ref symfony/symfony#26486 Commits ------- 65d100e [HttpFoundation] Add info for getAcceptableFormats() method
2 parents d161cf3 + 65d100e commit fbca6db

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

components/http_foundation.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,21 @@ by using the following methods:
290290
:method:`Symfony\\Component\\HttpFoundation\\Request::getAcceptableContentTypes`
291291
Returns the list of accepted content types ordered by descending quality.
292292

293+
:method:`Symfony\\Component\\HttpFoundation\\Request::getAcceptableFormats`
294+
Returns the list of accepted client formats associated with the request.
295+
296+
Note that
297+
:method:`Symfony\\Component\\HttpFoundation\\Request::getAcceptableFormats`
298+
will use the data from
299+
:method:`Symfony\\Component\\HttpFoundation\\Request::getAcceptableContentTypes`
300+
and return the client acceptable formats::
301+
302+
$request->getAcceptableContentTypes();
303+
// returns ['text/html', 'application/xhtml+xml', 'application/xml', '*/*']
304+
305+
$request->getAcceptableFormats();
306+
// returns ['html', 'xml']
307+
293308
:method:`Symfony\\Component\\HttpFoundation\\Request::getLanguages`
294309
Returns the list of accepted languages ordered by descending quality.
295310

0 commit comments

Comments
 (0)