Chris@0: getRequest(); Chris@0: $result = $event->getControllerResult(); Chris@0: Chris@0: // If this is a render array then we assume that the router went with the Chris@0: // generic controller and not one with a format. If the format requested is Chris@0: // not HTML though, we can also assume that the requested format is invalid Chris@0: // so we provide a 406 response. Chris@0: if (is_array($result) && $request->getRequestFormat() !== 'html') { Chris@0: throw new NotAcceptableHttpException('Not acceptable format: ' . $request->getRequestFormat()); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public static function getSubscribedEvents() { Chris@0: $events[KernelEvents::VIEW][] = ['onRespond', -10]; Chris@0: return $events; Chris@0: } Chris@0: Chris@0: }