public function AcceptNegotiation406::onViewDetect406 in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php \Drupal\Core\EventSubscriber\AcceptNegotiation406::onViewDetect406()
Throws an HTTP 406 error if we get this far, which we normally shouldn't.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event: The event to process.
File
- core/
lib/ Drupal/ Core/ EventSubscriber/ AcceptNegotiation406.php, line 28 - Contains \Drupal\Core\EventSubscriber\AcceptNegotiation406.
Class
- AcceptNegotiation406
- View subscriber rendering a 406 if we could not route or render a request.
Namespace
Drupal\Core\EventSubscriberCode
public function onViewDetect406(GetResponseForControllerResultEvent $event) {
$request = $event
->getRequest();
$result = $event
->getControllerResult();
// If this is a render array then we assume that the router went with the
// generic controller and not one with a format. If the format requested is
// not HTML though we can also assume that the requested format is invalid
// so we provide a 406 response.
if (is_array($result) && $request
->getRequestFormat() !== 'html') {
throw new NotAcceptableHttpException('Not acceptable');
}
}