function EnforcedFormResponseSubscriber::onKernelException

Same name in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php \Drupal\Core\EventSubscriber\EnforcedFormResponseSubscriber::onKernelException()
  2. 10 core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php \Drupal\Core\EventSubscriber\EnforcedFormResponseSubscriber::onKernelException()
  3. 11.x core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php \Drupal\Core\EventSubscriber\EnforcedFormResponseSubscriber::onKernelException()

Replaces the response in case an EnforcedResponseException was thrown.

File

core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php, line 19

Class

EnforcedFormResponseSubscriber
Handle the EnforcedResponseException and deliver an EnforcedResponse.

Namespace

Drupal\Core\EventSubscriber

Code

public function onKernelException(GetResponseForExceptionEvent $event) {
    if ($response = EnforcedResponse::createFromException($event->getException())) {
        // Setting the response stops the event propagation.
        $event->setResponse($response);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.