Skip to content
Snippets Groups Projects
Commit b32d6772 authored by Larry Garfield's avatar Larry Garfield
Browse files

Make HTML the default output format. That is, make HTML the last format to...

Make HTML the default output format.  That is, make HTML the last format to catch output events and apply it to the catch-all accept header.
parent 7c2cb51e
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -31,7 +31,7 @@ class HtmlSubscriber implements EventSubscriberInterface {
* True if it is an event we should process as HTML, False otherwise.
*/
protected function isHtmlRequestEvent(GetResponseEvent $event) {
return in_array('text/html', $event->getRequest()->getAcceptableContentTypes());
return (boolean)array_intersect(array('text/html', '*/*'), $event->getRequest()->getAcceptableContentTypes());
}
/**
......@@ -96,11 +96,13 @@ public function onView(GetResponseEvent $event) {
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
$events[KernelEvents::EXCEPTION][] = array('onNotFoundHttpException');
$events[KernelEvents::EXCEPTION][] = array('onAccessDeniedException');
$events[KernelEvents::EXCEPTION][] = array('onMethodAllowedException');
// Since we want HTML to be our default, catch-all response type, give its
// listeners a very low priority so that they always check last.
$events[KernelEvents::EXCEPTION][] = array('onNotFoundHttpException', 5);
$events[KernelEvents::EXCEPTION][] = array('onAccessDeniedException', 5);
$events[KernelEvents::EXCEPTION][] = array('onMethodAllowedException', 5);
$events[KernelEvents::VIEW][] = array('onView');
$events[KernelEvents::VIEW][] = array('onView', 5);
return $events;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment