function DefaultExceptionSubscriber::isJsonApiExceptionEvent
Same name in other branches
- 9 core/modules/jsonapi/src/EventSubscriber/DefaultExceptionSubscriber.php \Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber::isJsonApiExceptionEvent()
- 10 core/modules/jsonapi/src/EventSubscriber/DefaultExceptionSubscriber.php \Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber::isJsonApiExceptionEvent()
- 11.x core/modules/jsonapi/src/EventSubscriber/DefaultExceptionSubscriber.php \Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber::isJsonApiExceptionEvent()
Check if the error should be formatted using JSON:API.
The JSON:API format is supported if the format is explicitly set or the request is for a known JSON:API route.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $exception_event: The exception event.
Return value
bool TRUE if it needs to be formatted using JSON:API. FALSE otherwise.
1 call to DefaultExceptionSubscriber::isJsonApiExceptionEvent()
- DefaultExceptionSubscriber::onException in core/
modules/ jsonapi/ src/ EventSubscriber/ DefaultExceptionSubscriber.php - Handles errors for this subscriber.
File
-
core/
modules/ jsonapi/ src/ EventSubscriber/ DefaultExceptionSubscriber.php, line 78
Class
- DefaultExceptionSubscriber
- Serializes exceptions in compliance with the JSON:API specification.
Namespace
Drupal\jsonapi\EventSubscriberCode
protected function isJsonApiExceptionEvent(GetResponseForExceptionEvent $exception_event) {
$request = $exception_event->getRequest();
$parameters = $request->attributes
->all();
return $request->getRequestFormat() === 'api_json' || (bool) Routes::getResourceTypeNameFromParameters($parameters);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.