class EnforcedFormResponseSubscriber
Same name in other branches
- 9 core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php \Drupal\Core\EventSubscriber\EnforcedFormResponseSubscriber
- 10 core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php \Drupal\Core\EventSubscriber\EnforcedFormResponseSubscriber
- 11.x 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
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
EnforcedFormResponseSubscriber::getSubscribedEvents | public static | function | |
EnforcedFormResponseSubscriber::onKernelException | public | function | Replaces the response in case an EnforcedResponseException was thrown. |
EnforcedFormResponseSubscriber::onKernelResponse | public | function | Unwraps an enforced response. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.