class EnforcedFormResponseSubscriber in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php \Drupal\Core\EventSubscriber\EnforcedFormResponseSubscriber
Handle the EnforcedResponseException and deliver an EnforcedResponse.
Hierarchy
- class \Drupal\Core\EventSubscriber\EnforcedFormResponseSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of EnforcedFormResponseSubscriber
1 string reference to 'EnforcedFormResponseSubscriber'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses EnforcedFormResponseSubscriber
File
- core/
lib/ Drupal/ Core/ EventSubscriber/ EnforcedFormResponseSubscriber.php, line 14
Namespace
Drupal\Core\EventSubscriberView source
class EnforcedFormResponseSubscriber implements EventSubscriberInterface {
/**
* Replaces the response in case an EnforcedResponseException was thrown.
*/
public function onKernelException(GetResponseForExceptionEvent $event) {
if ($response = EnforcedResponse::createFromException($event
->getException())) {
// Setting the response stops the event propagation.
$event
->setResponse($response);
}
}
/**
* Unwraps an enforced response.
*/
public function onKernelResponse(FilterResponseEvent $event) {
$response = $event
->getResponse();
if ($response instanceof EnforcedResponse && $event
->isMasterRequest()) {
$event
->setResponse($response
->getResponse());
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::EXCEPTION] = [
'onKernelException',
128,
];
$events[KernelEvents::RESPONSE] = [
'onKernelResponse',
128,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EnforcedFormResponseSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
EnforcedFormResponseSubscriber:: |
public | function | Replaces the response in case an EnforcedResponseException was thrown. | |
EnforcedFormResponseSubscriber:: |
public | function | Unwraps an enforced response. |