File tree Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -1586,20 +1586,17 @@ public function isNoCache()
15861586 */
15871587 public function getPreferredFormat (?string $ default = 'html ' ): ?string
15881588 {
1589- if (null !== $ this ->preferredFormat ) {
1589+ if (null !== $ this ->preferredFormat || null !== $ this -> preferredFormat = $ this -> getRequestFormat ( null ) ) {
15901590 return $ this ->preferredFormat ;
15911591 }
15921592
1593- $ preferredFormat = null ;
1594- foreach ($ this ->getAcceptableContentTypes () as $ contentType ) {
1595- if ($ preferredFormat = $ this ->getFormat ($ contentType )) {
1596- break ;
1593+ foreach ($ this ->getAcceptableContentTypes () as $ mimeType ) {
1594+ if ($ this ->preferredFormat = $ this ->getFormat ($ mimeType )) {
1595+ return $ this ->preferredFormat ;
15971596 }
15981597 }
15991598
1600- $ this ->preferredFormat = $ this ->getRequestFormat ($ preferredFormat ?: $ this ->getContentType ());
1601-
1602- return $ this ->preferredFormat ?: $ default ;
1599+ return $ default ;
16031600 }
16041601
16051602 /**
Original file line number Diff line number Diff line change @@ -408,12 +408,10 @@ public function testGetPreferredFormat()
408408
409409 $ request ->setRequestFormat ('atom ' );
410410 $ request ->headers ->set ('Accept ' , 'application/ld+json ' );
411- $ request ->headers ->set ('Content-Type ' , 'application/merge-patch+json ' );
412411 $ this ->assertSame ('atom ' , $ request ->getPreferredFormat ());
413412
414413 $ request = new Request ();
415414 $ request ->headers ->set ('Accept ' , 'application/xml ' );
416- $ request ->headers ->set ('Content-Type ' , 'application/json ' );
417415 $ this ->assertSame ('xml ' , $ request ->getPreferredFormat ());
418416
419417 $ request = new Request ();
You can’t perform that action at this time.
0 commit comments